private bool CompareHash(byte[] argument, byte[] etalon) { if (HashLength != etalon.Length) { throw new ArgumentOutOfRangeException(nameof(etalon)); } byte[] hash; using (MD4 md4 = new MD4Managed()) { hash = md4.ComputeHash(argument); } if (HashLength != hash.Length) { return(false); } for (int pos = 0; pos < HashLength; pos++) { if (hash[pos] != etalon[pos]) { return(false); } } return(true); }
public static byte[] ComputeHash(byte[] input) { MD4Managed managed = new MD4Managed(); managed.Initialize(); return(managed.ComputeHash(input)); }
public static string GetHashString(string s) { if (string.IsNullOrEmpty(s)) { return(null); } var baValue = Encoding.GetBytes(s); var md4 = new MD4Managed(); var baHash = md4.ComputeHash(baValue); return(BitConverter.ToString(baHash, 0).Replace("-", string.Empty)); }