[][src]Function devolutions_crypto::utils::derive_key

pub fn derive_key(
    key: &[u8],
    salt: &[u8],
    iterations: usize,
    length: usize
) -> Vec<u8>

Derives a key or password into a new one.

Arguments

  • key - The key to derive.
  • salt - The cryptographic salt to be used to add randomness. Can be empty.
  • 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;
let key = b"this is a secret password";
let salt = b"this is a salt";
let iterations = 10000;
let length = 32;

let new_key = derive_key(key, salt, iterations, length);

assert_eq!(32, new_key.len());