Function scrypt

Source
pub fn scrypt(
    pass: impl AsRef<[u8]>,
    salt: impl AsRef<[u8]>,
    output_len: usize,
) -> Vec<u8> 
Expand description

Computes the scrypt key derivation function using recommended parameters.

§Arguments

  • pass - The password or passphrase as a byte slice.
  • salt - The salt as a byte slice.
  • output_len - The desired length of the derived key in bytes. Must be greater than 9 and less than or equal to 64.

§Returns

A Vec<u8> containing the derived key of the specified length.

§Panics

Panics if the scrypt function fails or if the output length is invalid.

§Examples

use bc_crypto::scrypt;
let key = scrypt(b"password", b"salt", 32);
assert_eq!(key.len(), 32);