mirror of
https://github.com/Jackett/Jackett.git
synced 2025-12-20 13:26:59 +01:00
* core: refactor obsolete hashing calls * core: delete cert callback validation removal in update service * core: remove deprecated ServicePointManager calls - Avoid harcoding SSL protocols. - Lowering DefaultConnectionLimit 1000 to MaxConnectionsPerServer 20 * core: avoid is only supported on windows warnings
35 lines
847 B
C#
35 lines
847 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Jackett.Common.Extensions
|
|
{
|
|
public static class HashingExtensions
|
|
{
|
|
public static string SHA1Hash(this string input)
|
|
{
|
|
using var hash = SHA1.Create();
|
|
|
|
return GetHash(hash.ComputeHash(Encoding.UTF8.GetBytes(input)));
|
|
}
|
|
|
|
public static string SHA256Hash(this string input)
|
|
{
|
|
using var hash = SHA256.Create();
|
|
|
|
return GetHash(hash.ComputeHash(Encoding.UTF8.GetBytes(input)));
|
|
}
|
|
|
|
private static string GetHash(byte[] bytes)
|
|
{
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
foreach (var b in bytes)
|
|
{
|
|
stringBuilder.Append(b.ToString("x2"));
|
|
}
|
|
|
|
return stringBuilder.ToString();
|
|
}
|
|
}
|
|
}
|