Function argon2::hash_encoded

source ·
pub fn hash_encoded(
    pwd: &[u8],
    salt: &[u8],
    config: &Config<'_>
) -> Result<String>
Expand description

Hashes the password and returns the encoded hash.

Examples

Create an encoded hash with the default configuration:

use argon2::{self, Config};

let pwd = b"password";
let salt = b"somesalt";
let config = Config::default();
let encoded = argon2::hash_encoded(pwd, salt, &config).unwrap();

Create an Argon2d encoded hash with 4 lanes:

use argon2::{self, Config, Variant};

let pwd = b"password";
let salt = b"somesalt";
let mut config = Config::default();
config.variant = Variant::Argon2d;
config.lanes = 4;
let encoded = argon2::hash_encoded(pwd, salt, &config).unwrap();