C # HmacSha512 is encrypted with Java HmacSha512.
/// <summary> ///HmacSha512 Encryption/// </summary> /// <param name= "Clearmessage" ></param> /// <param name= "secretkeystring" ></param> /// <returns></returns> protected stringHMACSHA512 (stringClearmessage,stringsecretkeystring) {Encoding Encoder=Encoding.UTF8; //Transform the clear query string to a byte array byte[] Messagebytes =Encoder. GetBytes (Clearmessage); //Transform The secret key string to a byte array varKey =convert.tobase64string (encoder. GetBytes (secretkeystring)); byte[] Secretkeybytes =Encoder. GetBytes (key); //Init the Hmac SHA512 generator with the keyHMACSHA512 hmacsha512 =NewHMACSHA512 (secretkeybytes); //Hash the message byte[] HashValue =Hmacsha512.computehash (messagebytes); //Transform the hash bytes array to a string string stringHMAC = bitconverter.tostring (hashValue). Replace ("-",""); //Force the case of the HMAC key to uppercase returnHMAC. ToLower (); }
C # HmacSha512 and Java HmacSha512 encryption