1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-17 15:46:33 +09:00

NetSha.Hash made thread safe

This commit is contained in:
lidgren
2010-09-26 13:16:09 +00:00
parent 3b0c33fa8a
commit 5e95651649

View File

@@ -143,12 +143,16 @@ namespace Lidgren.Network
{ {
// TODO: switch to SHA256 // TODO: switch to SHA256
private static SHA1 m_sha; private static SHA1 m_sha;
private static object s_lock = new object();
public static byte[] Hash(byte[] data) public static byte[] Hash(byte[] data)
{ {
if (m_sha == null) lock (s_lock)
m_sha = SHA1Managed.Create(); {
return m_sha.ComputeHash(data); if (m_sha == null)
m_sha = SHA1Managed.Create();
return m_sha.ComputeHash(data);
}
} }
} }