Skip to main content

hash_password

Function hash_password 

Source
pub fn hash_password(
    password: &[u8],
    version: PasswordHashVersion,
) -> Result<PasswordHash>
Expand description

Creates a PasswordHash containing the password verifier.

Uses a secure default for each version:

  • V1 (PBKDF2-HMAC-SHA256): DEFAULT_PBKDF2_ITERATIONS iterations.
  • V2 / Latest (Argon2id): 64 MiB memory, 3 time iterations (OWASP recommendation).

Use hash_password_with_parameters when you need to tune the algorithm parameters.

§Arguments

  • password - The password to hash.
  • version - Version of the algorithm to use. Use PasswordHashVersion::Latest if you’re not dealing with shared data.

§Returns

Returns the PasswordHash containing the password verifier.

§Example

use devolutions_crypto::password_hash::{hash_password, PasswordHashVersion};

let password = b"somesuperstrongpa$$w0rd!";

let hashed_password = hash_password(password, PasswordHashVersion::Latest);