[go: up one dir, main page]

Crate scrypt

Crate scrypt 

Source
Expand description

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)

// NOTE: example requires `getrandom` feature is enabled

use scrypt::{
    password_hash::{
        PasswordHasher, PasswordVerifier, phc::{PasswordHash, Salt}
    },
    Scrypt
};

let password = b"hunter42"; // Bad password; don't actually use!

// Hash password to PHC string ($scrypt$...)
let password_hash = Scrypt.hash_password(password)?.to_string();

// Verify password against PHC string
let parsed_hash = PasswordHash::new(&password_hash)?;
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;password-hash

Modules§

errors
Errors for scrypt operations.

Structs§

Params
The Scrypt parameter values.
Scryptpassword-hash
scrypt type for use with PasswordHasher.

Constants§

ALG_IDpassword-hash
Algorithm identifier

Functions§

scrypt
The scrypt key derivation function.