{"id":57199,"library":"hmac","title":"hmac","description":"Generic implementation of Hash-based Message Authentication Code (HMAC).","status":"active","version":"0.13.0","language":"rust","source_language":null,"source_url":"https://github.com/RustCrypto/MACs","tags":["hmac","authentication","crypto","mac"],"install":[{"cmd":"# Cargo.toml\n[dependencies]\nhmac = \"0.13.0\"","lang":"toml","label":"Cargo.toml"},{"cmd":"cargo add hmac","lang":"bash","label":"cargo add"}],"dependencies":[],"imports":[{"symbol":"Hmac","correct":"use hmac::Hmac;"}],"quickstart":{"code":"use hmac::{Hmac, Mac, NewMac};\nuse sha2::Sha256;\n\nfn main() {\n    let mut mac = Hmac::<Sha256>::new_from_slice(b\"my secret key\").unwrap();\n    mac.update(b\"message\");\n    let result = mac.finalize();\n    let code = result.into_bytes();\n    println!(\"HMAC: {:x?}\", code);\n}","lang":"rust","description":"Compute HMAC-SHA256 for a message."},"warnings":[{"fix":"Add sha2 as a dependency and use it as the type parameter.","message":"Requires a hash function crate like sha2 or sha3.","severity":"gotcha","affected_versions":">=0.12.0"}],"env_vars":null,"search_vec":"'authent':9,13 'base':7 'code':10 'crypto':14 'generic':2 'hash':6 'hash-bas':5 'hmac':1,11,12 'implement':3 'mac':15 'messag':8","created_at":"2026-06-16T15:32:29.629317+00:00","updated_at":"2026-06-16T15:32:29.629317+00:00","problems":[],"ecosystem":"crates","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/RustCrypto/MACs","github":"https://github.com/RustCrypto/MACs","docs":"https://docs.rs/hmac/","changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["crypto"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-16","next_check":"2026-12-13","install_tag":null}}