Added GetNewMasterPass state and added restrictions on the master password

This commit is contained in:
2023-06-04 20:41:10 +03:00
parent 4d4cec1353
commit 9d0fa17a0e
7 changed files with 79 additions and 3 deletions

View File

@ -2,7 +2,7 @@
pub mod account;
pub mod master_pass;
pub mod password_generation;
pub mod passwords;
pub mod prelude;
#[derive(thiserror::Error, Debug)]

View File

@ -50,3 +50,28 @@ fn generate_password() -> ArrayString<32> {
pub fn generate_passwords() -> [ArrayString<32>; 10] {
array::from_fn(|_| generate_password())
}
#[inline]
pub fn check_master_pass(password: &str) -> bool {
if password.chars().count() < 8 {
return false;
}
let mut flags = PasswordFlags::empty();
for char in password.chars() {
if char.is_lowercase() {
flags |= PasswordFlags::LOWERCASE
} else if char.is_uppercase() {
flags |= PasswordFlags::UPPERCASE
} else if char.is_ascii_digit() {
flags |= PasswordFlags::NUMBER;
} else if char.is_ascii_punctuation() {
flags |= PasswordFlags::SPECIAL_CHARACTER
}
if flags.is_all() {
return true;
}
}
false
}