Skip to main content

pbkdf2_array

Function 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,
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, hmac::Hmac, 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"));

ยงErrors

Returns InvalidLength if the length of password is unsupported by PRF.