1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 15:16: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
private static SHA1 m_sha;
private static object s_lock = new object();
public static byte[] Hash(byte[] data)
{
if (m_sha == null)
m_sha = SHA1Managed.Create();
return m_sha.ComputeHash(data);
lock (s_lock)
{
if (m_sha == null)
m_sha = SHA1Managed.Create();
return m_sha.ComputeHash(data);
}
}
}