get back to where we were. but now with sea_orm and a more sane structure
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-14 22:29:35 +02:00
parent 35bde07b39
commit e33a734199
26 changed files with 126 additions and 312 deletions

1
neo-util/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
pub mod password;

17
neo-util/src/password.rs Normal file
View File

@@ -0,0 +1,17 @@
use argon2::{password_hash::SaltString, Argon2, PasswordHash, PasswordHasher, PasswordVerifier};
use rand::rngs::OsRng;
pub fn hash_password(password: &str) -> anyhow::Result<String> {
let argon2 = Argon2::default();
let salt = SaltString::generate(OsRng);
Ok(argon2
.hash_password(password.as_bytes(), &salt)?
.to_string())
}
pub fn password_correct(password: &str, hash: &str) -> anyhow::Result<bool> {
let password_hash = PasswordHash::new(hash)?;
Ok(Argon2::default()
.verify_password(password.as_bytes(), &password_hash)
.is_ok())
}