[−][src]Function devolutions_crypto::utils::derive_key
pub fn derive_key(
key: &[u8],
salt: &[u8],
iterations: usize,
length: usize
) -> Vec<u8>
Derives a password or key into a new one.
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, 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(key, &salt, iterations, length); assert_eq!(32, new_key.len());