You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 07:06:30 +09:00
NetSha.Hash made thread safe
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user