Function argon2::hash_encoded[][src]

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 and parallel execution:

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

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