Add option to consolidate duplicate ATA entities.

This commit is contained in:
2019-11-09 19:23:49 +00:00
parent d3b59108df
commit f7ea40cfb0
8 changed files with 172 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
using System.Security.Cryptography;
namespace DiscImageChef.Server
{
public static class Hash
{
public static string Sha512(byte[] data)
{
byte[] hash;
using(var sha = new SHA512Managed())
{
sha.Initialize();
hash = sha.ComputeHash(data);
}
char[] chars = new char[hash.Length * 2];
int j = 0;
foreach(byte b in hash)
{
int nibble1 = (b & 0xF0) >> 4;
int nibble2 = b & 0x0F;
nibble1 += nibble1 > 9 ? 0x57 : 0x30;
nibble2 += nibble2 > 9 ? 0x57 : 0x30;
chars[j++] = (char)nibble1;
chars[j++] = (char)nibble2;
}
return new string(chars);
}
}
}