Crate scrypt[][src]

This crate implements the Scrypt key derivation function as specified in [1].

If you are only using the low-level scrypt function instead of the higher-level Scrypt struct to produce/verify hash strings, it’s recommended to disable default features in your Cargo.toml:

[dependencies]
scrypt = { version = "0.2", default-features = false }

Usage (simple with default params)

use scrypt::{
    password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
    Scrypt
};
use rand_core::OsRng;

let password = b"hunter42"; // Bad password; don't actually use!
let salt = SaltString::generate(&mut OsRng);

// Hash password to PHC string ($scrypt$...)
let password_hash = Scrypt.hash_password_simple(password, salt.as_ref()).unwrap().to_string();

// Verify password against PHC string
let parsed_hash = PasswordHash::new(&password_hash).unwrap();
assert!(Scrypt.verify_password(password, &parsed_hash).is_ok());

References

[1] - C. Percival. Stronger Key Derivation Via Sequential Memory-Hard Functions

Re-exports

pub use password_hash;

Modules

errors

Errors for scrypt operations.

Structs

Params

The Scrypt parameter values.

Scryptsimple

scrypt type for use with PasswordHasher.

Constants

ALG_ID

Algorithm identifier

Functions

scrypt

The scrypt key derivation function.