diff --git a/src/RecentMessages.cs b/src/RecentMessages.cs index 4deb36b..187b229 100644 --- a/src/RecentMessages.cs +++ b/src/RecentMessages.cs @@ -16,9 +16,6 @@ namespace Makaretu.Dns /// public class RecentMessages { - // MD5 is okay because the hash is not used for security. - HashAlgorithm hasher = MD5.Create(); - /// /// Recent messages. /// @@ -84,7 +81,11 @@ public int Prune() /// public string GetId(byte[] message) { - return Convert.ToBase64String(hasher.ComputeHash(message)); + // MD5 is okay because the hash is not used for security. + using (HashAlgorithm hasher = MD5.Create()) + { + return Convert.ToBase64String(hasher.ComputeHash(message)); + } } } }