mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
fix(indexers): fixed and optimized xthor indexer
* feat(utils): added sha1 hash function and refactored md5 hash function * fix(indexers): now use cross plateform path building for dev mode * fix(indexers): fix output log of xthor for dev mode * feat(release): added ToString method * refactor(dev): optimized dev mode * style(clean): cleanup code * feat(indexer): added tmdb info to releases * fix(cat): enabled categories on xthor
This commit is contained in:
@@ -55,20 +55,46 @@ namespace Jackett.Utils
|
||||
return new FormUrlEncodedContent(dict).ReadAsStringAsync().Result;
|
||||
}
|
||||
|
||||
public static string Hash(string input)
|
||||
/// <summary>
|
||||
/// Convert an array of bytes to a string of hex digits
|
||||
/// </summary>
|
||||
/// <param name="bytes">array of bytes</param>
|
||||
/// <returns>String of hex digits</returns>
|
||||
public static string HexStringFromBytes(byte[] bytes)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
var hex = b.ToString("x2");
|
||||
sb.Append(hex);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute hash for string encoded as UTF8
|
||||
/// </summary>
|
||||
/// <param name="s">String to be hashed</param>
|
||||
/// <returns>40-character hex string</returns>
|
||||
public static string HashSHA1(string s)
|
||||
{
|
||||
var sha1 = SHA1.Create();
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(s);
|
||||
byte[] hashBytes = sha1.ComputeHash(bytes);
|
||||
|
||||
return HexStringFromBytes(hashBytes);
|
||||
}
|
||||
|
||||
public static string Hash(string s)
|
||||
{
|
||||
// Use input string to calculate MD5 hash
|
||||
MD5 md5 = System.Security.Cryptography.MD5.Create();
|
||||
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
|
||||
|
||||
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(s);
|
||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
// Convert the byte array to hexadecimal string
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hashBytes.Length; i++)
|
||||
{
|
||||
sb.Append(hashBytes[i].ToString("X2"));
|
||||
}
|
||||
return sb.ToString();
|
||||
return HexStringFromBytes(hashBytes);
|
||||
}
|
||||
|
||||
public static string GetExceptionDetails(this Exception exception)
|
||||
|
Reference in New Issue
Block a user