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