pub async fn verify_password(entered_password: String, stored_password_hash: String) -> Result<(), anyhow::Error> {
    Ok(tokio::task::spawn_blocking(move || -> Result<(), anyhow::Error> {
        let hash = PasswordHash::new(&stored_password_hash)
            .map_err(|e| anyhow::anyhow!("invalid password hash: {}", e))?;

        hash.verify_password(&[&Argon2::default()], entered_password)
            .map_err(|e| match e {
                argon2::password_hash::Error::Password => anyhow!("Mot de passe inexact").into(),
                _ => anyhow::anyhow!("failed to verify password hash: {}", e).into(),
            })
    })
        .await
        .context("panic in verifying password hash")??)
}
///
/// Function verify_password
/// 1) password to verify
/// 2) stored password
///
/// uses argon2
///

Function verify_password
1) password to verify
2) stored password

uses argon2
Function verify_password 1 ) password to verify 2 ) stored password uses argon2
pub async fn verify_password(entered_password: String, stored_password_hash: String) -> Result<(), anyhow::Error> {
    Ok(tokio::task::spawn_blocking(move || -> Result<(), anyhow::Error> {
        let hash = PasswordHash::new(&stored_password_hash)
            .map_err(|e| anyhow::anyhow!("invalid password hash: {}", e))?;
        hash.verify_password(&[&Argon2::default()], entered_password)
            .map_err(|e| match e {
                argon2::password_hash::Error::Password => anyhow!("Mot de passe inexact").into(),
                _ => anyhow::anyhow!("failed to verify password hash: {}", e).into(),
            })
    })
        .await
        .context("panic in verifying password hash")??)
}
pub async fn verify_password ( entered_password : String , stored_password_hash : String ) -> Result < ( ) , anyhow :: Error > { Ok ( tokio :: task :: spawn_blocking ( move | | -> Result < ( ) , anyhow :: Error > { let hash = PasswordHash :: new ( & stored_password_hash ) . map_err ( | e | anyhow :: anyhow ! ( " " e ) ) ? ; hash . verify_password ( & [ & Argon2 :: default ( ) ] , entered_password ) . map_err ( | e | match e { argon2 :: password_hash :: Error :: Password => anyhow ! ( " " ) . into ( ) , _ => anyhow :: anyhow ! ( " " e ) . into ( ) , } ) } ) . await . context ( " " ) ? ? ) }
Function verify_password
1) password to verify
2) stored password
Function verify_password 1 ) password to verify 2 ) stored password
entered_password
String
stored_password_hash
String