public static string RIPEMD160(string baseStr, string key) { var sourceBytes = utf8Enc.GetBytes(baseStr); var keyBytes = utf8Enc.GetBytes(key); var ripemd160 = new HMACRIPEMD160(keyBytes); var hashBytes = ripemd160.ComputeHash(sourceBytes); ripemd160.Clear(); var hashStr = string.Empty; foreach (var hashByte in hashBytes) { hashStr += string.Format("{0,0:x2}", hashByte); } return(hashStr); }
} //compute hash from arguments and return hash value as string private static string GetHMACRIPEMD160Hash(string text) { //create variables for computing hash and making it a string UnicodeEncoding UniCode = new UnicodeEncoding(); byte[] HashResult; byte[] msg = UniCode.GetBytes(text); HMACRIPEMD160 hashString = new HMACRIPEMD160(); string Str = ""; //compute hash with HMACRIPEMD160 module and format output as string //convert bytes in HashResult to string values HashResult = hashString.ComputeHash(msg); foreach (byte x in HashResult) { Str += String.Format("{0:x2}", x); } //clear excess resource usage hashString.Clear(); return(Str); } //compute hash from arguments and return hash value as string