MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / verify_password

Function verify_password

ch_10/src/routes/authentication.rs:73–83  ·  view source on GitHub ↗
(
    hash: &str,
    password: &[u8],
)

Source from the content-addressed store, hash-verified

71}
72
73fn verify_password(
74 hash: &str,
75 password: &[u8],
76) -> Result<bool, argon2::password_hash::Error> {
77 let parsed_hash = PasswordHash::new(hash)?;
78 match Argon2::default().verify_password(password, &parsed_hash) {
79 Ok(()) => Ok(true),
80 Err(argon2::password_hash::Error::Password) => Ok(false),
81 Err(e) => Err(e),
82 }
83}
84
85fn make_key() -> PasetoSymmetricKey<V4, PasetoLocal> {
86 let key_str = env::var("PASETO_KEY").unwrap();

Callers 1

loginFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected