public string GetHash(byte[] chunkdata) { HashTableHashing.SuperFastHashSimple sfh = new HashTableHashing.SuperFastHashSimple(); HashTableHashing.MurmurHash2Simple mm2h = new HashTableHashing.MurmurHash2Simple(); xxHash xxhash = new xxHash(); xxhash.Init(); xxhash.Update(chunkdata, chunkdata.Count()); string hash = ""; uint h1 = sfh.Hash(chunkdata); uint h2 = mm2h.Hash(chunkdata); uint h3 = xxhash.Digest(); BigInteger h = (BigInteger)h1 * (BigInteger)h2 * (BigInteger)h3; hash = h.ToString() + h1.ToString() + h2.ToString() + h3.ToString(); // byte array representation of that string byte[] encodedhash = new UTF8Encoding().GetBytes(hash); // need MD5 to calculate the hash byte[] md5hash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedhash); // string representation (similar to UNIX format) string encoded = BitConverter.ToString(md5hash) // without dashes .Replace("-", string.Empty) // make lowercase .ToLower(); return(encoded); }
public string GetHash(byte[] chunkdata) { HashTableHashing.SuperFastHashSimple sfh = new HashTableHashing.SuperFastHashSimple(); HashTableHashing.MurmurHash2Simple mm2h = new HashTableHashing.MurmurHash2Simple(); xxHash xxhash = new xxHash(); xxhash.Init(); xxhash.Update(chunkdata, chunkdata.Count()); string hash = ""; uint h1 = sfh.Hash(chunkdata); uint h2 = mm2h.Hash(chunkdata); uint h3 = xxhash.Digest(); BigInteger h = (BigInteger)h1 * (BigInteger)h2 * (BigInteger)h3; hash = h.ToString() + h1.ToString()+h2.ToString()+h3.ToString(); // byte array representation of that string byte[] encodedhash = new UTF8Encoding().GetBytes(hash); // need MD5 to calculate the hash byte[] md5hash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedhash); // string representation (similar to UNIX format) string encoded = BitConverter.ToString(md5hash) // without dashes .Replace("-", string.Empty) // make lowercase .ToLower(); return encoded; }