Files
Jackett-Jackett/src/Jackett.Common/Extensions/HashingExtensions.cs
Bogdan 61b263dd98 core: refactor obsolete calls (#16290)
* 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
2025-11-16 22:05:22 +02:00

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();
}
}
}