mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-09 07:00:06 +03:00
finish implementing features, add logging, windows-specific features
This commit is contained in:
@@ -36,3 +36,26 @@ pub (crate) fn parse_idm_hex(idm_hex: &String) -> Option<[u8; 8]> {
|
||||
|
||||
Some(idm_bytes)
|
||||
}
|
||||
|
||||
pub (crate) fn is_valid_access_code(code: &String) -> bool {
|
||||
if code.len() > 20 {
|
||||
return false;
|
||||
}
|
||||
|
||||
let cleaned_code: String = code.chars().filter(|c| !c.is_whitespace()).collect();
|
||||
|
||||
if cleaned_code.len() != 20 {
|
||||
return false;
|
||||
}
|
||||
|
||||
let mut seen_non_zero = false;
|
||||
let is_all_digits = cleaned_code.chars().all(|c| {
|
||||
if c != '0' {
|
||||
seen_non_zero = true;
|
||||
}
|
||||
|
||||
c.is_ascii_digit()
|
||||
});
|
||||
|
||||
is_all_digits && seen_non_zero
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user