From 0138b7645dd09576a10515e6d9934923460aede8 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Tue, 10 Dec 2024 09:24:26 +0000 Subject: [PATCH] feat: shuffle the character set with `StdRng` and utilise uppercase characters --- src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index c550654..078d3bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,12 +11,15 @@ struct Args { } fn hash(input: Vec) -> String { - let characters = "abcdefghijklmnopqrstuvwxyz".chars().collect::>(); - let numbers = "0123456789".chars().collect::>(); - 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::>(); + let mut characters = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ".chars().collect::>(); + 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) -> 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()