use hmac::{Hmac, KeyInit, Mac};
use sha2::Sha256;
type HmacSha256 = Hmac<Sha256>;
#[expect(
clippy::expect_used,
reason = "HMAC-SHA256 accepts any key length by construction; new_from_slice cannot fail here"
)]
pub fn hmac_sha256(pepper: &[u8], value: &[u8]) -> [u8; 32] {
let mut mac = HmacSha256::new_from_slice(pepper).expect("HMAC accepts any key length");
mac.update(value);
let result = mac.finalize().into_bytes();
let mut out = [0u8; 32];
out.copy_from_slice(&result);
out
}
pub fn hmac_sha256_hex(pepper: &[u8], value: &[u8]) -> String {
hex::encode(hmac_sha256(pepper, value))
}