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

Function verify_password

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

Source from the content-addressed store, hash-verified

57}
58
59fn verify_password(
60 hash: &str,
61 password: &[u8],
62) -> Result<bool, argon2::password_hash::Error> {
63 let parsed_hash = PasswordHash::new(hash)?;
64 match Argon2::default().verify_password(password, &parsed_hash) {
65 Ok(()) => Ok(true),
66 Err(argon2::password_hash::Error::Password) => Ok(false),
67 Err(e) => Err(e),
68 }
69}
70
71fn make_key() -> PasetoSymmetricKey<V4, PasetoLocal> {
72 let key_str = env::var("PASETO_KEY").unwrap();

Callers 1

loginFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected