Skip to main content

hmac_sha256

Function hmac_sha256 

Source
pub fn hmac_sha256(key: &[u8], message: &[u8]) -> [u8; 32]
Expand description

Computes HMAC-SHA256 over a message with a key of any length.

§Arguments

  • key - the secret key; any length is accepted, as HMAC defines.
  • message - the bytes to authenticate.

§Returns

The 32-byte message authentication code.

§Examples

// RFC 4231 test case 2.
let mac = pamoja_session::hmac_sha256(b"Jefe", b"what do ya want for nothing?");
assert_eq!(mac[..4], [0x5b, 0xdc, 0xc1, 0x46]);