Registry / crypto / hmac
library0.13.0rscratesunverified

Generic implementation of Hash-based Message Authentication Code (HMAC).

# Cargo.toml [dependencies] hmac = "0.13.0"
INSTALL
IMPORT
SIG · HMAC
H
hmac
cryptorustv0.13.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Hmac
use hmac::Hmac;

Compute HMAC-SHA256 for a message.

use hmac::{Hmac, Mac, NewMac}; use sha2::Sha256; fn main() { let mut mac = Hmac::<Sha256>::new_from_slice(b"my secret key").unwrap(); mac.update(b"message"); let result = mac.finalize(); let code = result.into_bytes(); println!("HMAC: {:x?}", code); }
Debug
Known issues
gotchaRequires a hash function crate like sha2 or sha3.
fix
Add sha2 as a dependency and use it as the type parameter.
affects: >=0.12.0
Upgrade
Version history
0.13.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
hmac — cargo add hmac · libregistry