Function argon2::hash_encoded [] [src]

pub fn hash_encoded(variant: Variant,
                    version: Version,
                    mem_cost: u32,
                    time_cost: u32,
                    lanes: u32,
                    threads: u32,
                    pwd: &[u8],
                    salt: &[u8],
                    secret: &[u8],
                    ad: &[u8],
                    hash_len: u32)
                    -> Result<String>

Hashes the password and returns the encoded hash.

Examples

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

let mem_cost = 4096;
let time_cost = 10;
let lanes = 1;
let threads = 1;
let pwd = b"password";
let salt = b"somesalt";
let secret = b"secret value";
let ad = b"associated data";
let hash_len = 32;
let encoded = argon2::hash_encoded(Variant::Argon2i,
                                   Version::Version13,
                                   mem_cost,
                                   time_cost,
                                   lanes,
                                   threads,
                                   pwd,
                                   salt,
                                   secret,
                                   ad,
                                   hash_len).unwrap();

Remarks

The only sensible values for threads are 1 and the number of lanes.