MCPcopy Create free account
hub / github.com/actix/examples / hash_password

Function hash_password

auth/simple-auth-server/src/utils.rs:11–20  ·  view source on GitHub ↗

PLEASE NOTE THIS IS ONLY FOR DEMO PLEASE DO MORE RESEARCH FOR PRODUCTION USE

(password: &str)

Source from the content-addressed store, hash-verified

9
10// PLEASE NOTE THIS IS ONLY FOR DEMO PLEASE DO MORE RESEARCH FOR PRODUCTION USE
11pub fn hash_password(password: &str) -> Result<String, ServiceError> {
12 let config = argon2::Config {
13 secret: SECRET_KEY.as_bytes(),
14 ..argon2::Config::rfc9106_low_mem()
15 };
16 argon2::hash_encoded(password.as_bytes(), SALT, &config).map_err(|err| {
17 dbg!(err);
18 ServiceError::InternalServerError
19 })
20}
21
22pub fn verify(hash: &str, password: &str) -> Result<bool, ServiceError> {
23 argon2::verify_encoded_ext(hash, password.as_bytes(), SECRET_KEY.as_bytes(), &[]).map_err(

Callers 1

queryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected