amebazii::util

Function hmac_md5

Source
pub fn hmac_md5(key: &[u8], data: &[u8]) -> Result<[u8; 16], Error>
Expand description

Computes an HMAC-MD5 signature for the provided key and data.

This function generates an HMAC (Hash-based Message Authentication Code) using the MD5 hashing algorithm. The key and data are processed, and the resulting 128-bit (16-byte) signature is returned.

§Parameters

  • key: A byte slice representing the secret key used for the HMAC computation.
  • data: A byte slice containing the data to be authenticated.

§Returns

  • [u8; 16]: A 16-byte array containing the HMAC-MD5 signature.
  • Err(error::Error): An error if there is a failure during the HMAC computation (e.g., key or data issues, cryptographic errors).

§Example

use amebazii::util::hmac_md5;

let key = b"secret";
let data = b"message";
let signature = hmac_md5(key, data).unwrap();
assert_eq!(signature.len(), 16); // The HMAC-MD5 signature should be 16 bytes.

§Errors

This function may return an error if any step in the HMAC-MD5 computation fails.