1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 08:06: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,14 +143,18 @@ 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)
{
lock (s_lock)
{ {
if (m_sha == null) if (m_sha == null)
m_sha = SHA1Managed.Create(); m_sha = SHA1Managed.Create();
return m_sha.ComputeHash(data); return m_sha.ComputeHash(data);
} }
} }
}
public static class NetSRP public static class NetSRP
{ {