PLEASE NOTE THIS IS ONLY FOR DEMO PLEASE DO MORE RESEARCH FOR PRODUCTION USE
(password: &str)
| 9 | |
| 10 | // PLEASE NOTE THIS IS ONLY FOR DEMO PLEASE DO MORE RESEARCH FOR PRODUCTION USE |
| 11 | pub 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 | |
| 22 | pub fn verify(hash: &str, password: &str) -> Result<bool, ServiceError> { |
| 23 | argon2::verify_encoded_ext(hash, password.as_bytes(), SECRET_KEY.as_bytes(), &[]).map_err( |