feat: shuffle the character set with StdRng and utilise uppercase characters

This commit is contained in:
Muhammad Nauman Raza 2024-12-10 09:24:26 +00:00
parent 052f3e380d
commit 0138b7645d
Signed by: devraza
GPG key ID: 91EAD6081011574B

View file

@ -11,12 +11,15 @@ struct Args {
}
fn hash(input: Vec<u8>) -> String {
let characters = "abcdefghijklmnopqrstuvwxyz".chars().collect::<Vec<char>>();
let numbers = "0123456789".chars().collect::<Vec<char>>();
let mut hash: u64 = 0;
let prime: u64 = 67_280_421_310_721;
let mut rng = StdRng::seed_from_u64(prime);
let numbers = "0123456789".chars().collect::<Vec<char>>();
let mut characters = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ".chars().collect::<Vec<char>>();
characters.shuffle(&mut rng);
for (i, c) in input.iter().enumerate() {
hash = hash.wrapping_mul(prime).wrapping_add(*c as u64 + i as u64);
}
@ -34,7 +37,7 @@ fn hash(input: Vec<u8>) -> String {
}
}
let mut rng = StdRng::seed_from_u64(hash);
rng = StdRng::seed_from_u64(hash);
hash_vector.shuffle(&mut rng);
hash_vector[0..64].iter().collect()