Skip to content

Commit

Permalink
Merge pull request #76 from Luai-m/master
Browse files Browse the repository at this point in the history
Make RecentMessages thread safe
  • Loading branch information
richardschneider authored Aug 27, 2019
2 parents db044dc + 0e72be0 commit 597bc97
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/RecentMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace Makaretu.Dns
/// </remarks>
public class RecentMessages
{
// MD5 is okay because the hash is not used for security.
HashAlgorithm hasher = MD5.Create();

/// <summary>
/// Recent messages.
/// </summary>
Expand Down Expand Up @@ -84,7 +81,11 @@ public int Prune()
/// </returns>
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));
}
}
}
}

0 comments on commit 597bc97

Please sign in to comment.