pub fn pbkdf2<PRF>(
password: &[u8],
salt: &[u8],
rounds: u32,
res: &mut [u8],
) -> Result<(), InvalidLength>
Expand description
Generic implementation of PBKDF2 algorithm which accepts an arbitrary keyed PRF.
use hex_literal::hex;
use pbkdf2::pbkdf2;
use hmac::Hmac;
use sha2::Sha256;
let mut buf = [0u8; 20];
pbkdf2::<Hmac<Sha256>>(b"password", b"salt", 600_000, &mut buf)
.expect("HMAC can be initialized with any key length");
assert_eq!(buf, hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"));