Improved the char counting in the check_master_pass function
This commit is contained in:
parent
c3af7e9a95
commit
0a1d125b04
@ -58,12 +58,11 @@ pub fn generate_passwords<const AMOUNT: usize, const LENGTH: usize>(
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn check_master_pass(password: &str) -> bool {
|
pub fn check_master_pass(password: &str) -> bool {
|
||||||
if password.chars().count() < 8 {
|
let mut count = 0;
|
||||||
return false;
|
let mut chars = password.chars();
|
||||||
}
|
|
||||||
|
|
||||||
let mut flags = PasswordFlags::empty();
|
let mut flags = PasswordFlags::empty();
|
||||||
for char in password.chars() {
|
for char in &mut chars {
|
||||||
|
count += 1;
|
||||||
if char.is_lowercase() {
|
if char.is_lowercase() {
|
||||||
flags |= PasswordFlags::LOWERCASE
|
flags |= PasswordFlags::LOWERCASE
|
||||||
} else if char.is_uppercase() {
|
} else if char.is_uppercase() {
|
||||||
@ -75,7 +74,8 @@ pub fn check_master_pass(password: &str) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if flags.is_all() {
|
if flags.is_all() {
|
||||||
return true;
|
count += chars.count();
|
||||||
|
return count >= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user