Function pbkdf2::pbkdf2_array

source ยท
pub fn pbkdf2_array<PRF, const N: usize>(
    password: &[u8],
    salt: &[u8],
    rounds: u32,
) -> Result<[u8; N], InvalidLength>
where PRF: KeyInit + Update + FixedOutput + Clone + Sync,
Expand description

A variant of the pbkdf2 function which returns an array instead of filling an input slice.

use hex_literal::hex;
use pbkdf2::pbkdf2_array;
use hmac::Hmac;
use sha2::Sha256;

let res = pbkdf2_array::<Hmac<Sha256>, 20>(b"password", b"salt", 600_000)
    .expect("HMAC can be initialized with any key length");
assert_eq!(res, hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"));