/// <summary>Signs a message with HMAC-SHA-512.</summary> /// <param name="message">The message.</param> /// <param name="key">The 32 byte key.</param> /// <returns>64 byte authentication code.</returns> /// <exception cref="KeyOutOfRangeException"></exception> public static byte[] SignHmacSha512(byte[] message, byte[] key) { //validate the length of the key if (key == null || key.Length != CRYPTO_AUTH_HMACSHA512_KEY_BYTES) { throw new KeyOutOfRangeException("key", (key == null) ? 0 : key.Length, string.Format("key must be {0} bytes in length.", CRYPTO_AUTH_HMACSHA512_KEY_BYTES)); } var buffer = new byte[CRYPTO_AUTH_HMACSHA512_BYTES]; SodiumLibrary.crypto_auth_hmacsha512(buffer, message, message.Length, key); return(buffer); }