pub fn derive_key_pbkdf2(
key: &[u8],
salt: &[u8],
iterations: u32,
length: usize,
) -> Vec<u8> ⓘExpand description
Derives a password or key into a new one using PBKDF2.
§Arguments
key- The key or password to derive.salt- The cryptographic salt to be used to add randomness. Can be empty. Recommended size is 16 bytes.iterations- The number of time the key will be derived. A higher number is slower but harder to brute-force. 10 000 iterations are recommended for a password.length- Length of the desired key.
§Example
use devolutions_crypto::utils::{derive_key_pbkdf2, generate_key};
let key = b"this is a secret password";
let salt = generate_key(16);
let iterations = 10000;
let length = 32;
let new_key = derive_key_pbkdf2(key, &salt, iterations, length);
assert_eq!(32, new_key.len());