don't share SHA256CryptoServiceProvider (can be improved)
parent
a23be00bf3
commit
65310f3e5e
|
@ -58,11 +58,6 @@ namespace OpenSim.Data.MySQL
|
|||
private bool m_enableCompression = false;
|
||||
private string m_connectionString;
|
||||
|
||||
/// <summary>
|
||||
/// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
|
||||
/// </summary>
|
||||
private HashAlgorithm hasher = new SHA256CryptoServiceProvider();
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version { get { return "1.0.0.0"; } }
|
||||
|
@ -250,7 +245,9 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
}
|
||||
|
||||
byte[] hash = hasher.ComputeHash(asset.Data);
|
||||
byte[] hash;
|
||||
using (HashAlgorithm hasher = new SHA256CryptoServiceProvider())
|
||||
hash = hasher.ComputeHash(asset.Data);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace OpenSim.Services.FSAssetService
|
|||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
||||
static SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider();
|
||||
|
||||
static byte[] ToCString(string s)
|
||||
{
|
||||
|
@ -357,7 +356,9 @@ namespace OpenSim.Services.FSAssetService
|
|||
|
||||
string GetSHA256Hash(byte[] data)
|
||||
{
|
||||
byte[] hash = SHA256.ComputeHash(data);
|
||||
byte[] hash;
|
||||
using (SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider())
|
||||
hash = SHA256.ComputeHash(data);
|
||||
|
||||
return BitConverter.ToString(hash).Replace("-", String.Empty);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue