Function scrypt::scrypt_simple [−][src]
pub fn scrypt_simple(password: &str, params: &ScryptParams) -> Result<String>
scrypt_simple
is a helper function that should be sufficient for the
majority of cases where an application needs to use Scrypt to hash a
password for storage. The result is a String that contains the parameters
used as part of its encoding. The scrypt_check
function may be used on
a password to check if it is equal to a hashed value.
Format
The format of the output is a modified version of the Modular Crypt Format
that encodes algorithm used and the parameter values. If all parameter
values can each fit within a single byte, a compact format is used
(format 0). However, if any value cannot, an expanded format where the
rand p
parameters are encoded using 4 bytes (format 1) is used. Both
formats use a 128-bit salt and a 256-bit hash. The format is indicated as
"rscrypt" which is short for "Rust Scrypt format."
$rscrypt$<format>$<base64(log_n,r,p)>$<base64(salt)>$<based64(hash)>$
Arguments
password
- The password to process as a strparams
- The ScryptParams to use
Return
Ok(String)
if calculation is succesfull with the computation result.
It will return io::Error
error in the case of an unlikely OsRng
failure.