mirror of
https://github.com/Radarr/Radarr
synced 2025-02-27 08:33:21 +00:00
HashAlgorithm.ComputerHash isn't thread safe,
This commit is contained in:
parent
852f97012f
commit
cce280d260
1 changed files with 6 additions and 5 deletions
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -8,12 +6,15 @@ namespace NzbDrone.Common.Crypto
|
||||||
{
|
{
|
||||||
public static class HashConverter
|
public static class HashConverter
|
||||||
{
|
{
|
||||||
private static SHA1 HashAlgorithm = SHA1.Create();
|
private static readonly SHA1 Sha1 = SHA1.Create();
|
||||||
|
|
||||||
public static int GetHashInt31(string target)
|
public static int GetHashInt31(string target)
|
||||||
{
|
{
|
||||||
var hash = HashAlgorithm.ComputeHash(Encoding.Default.GetBytes(target));
|
byte[] hash;
|
||||||
|
lock (Sha1)
|
||||||
|
{
|
||||||
|
hash = Sha1.ComputeHash(Encoding.Default.GetBytes(target));
|
||||||
|
}
|
||||||
return BitConverter.ToInt32(hash, 0) & 0x7fffffff;
|
return BitConverter.ToInt32(hash, 0) & 0x7fffffff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue