29 lines
755 B
Rust
29 lines
755 B
Rust
use md5::{Digest, Md5};
|
|
use std::{
|
|
collections::HashMap,
|
|
fs::File,
|
|
io::{BufWriter, Write},
|
|
};
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
let mut map = HashMap::new();
|
|
for i in 0u32..=std::u32::MAX {
|
|
let mut hasher = Md5::new();
|
|
hasher.update(i.to_le_bytes());
|
|
let out = hasher.finalize();
|
|
let key = out[out.len() - 1];
|
|
*map.entry(key).or_insert(0) += 1;
|
|
if i % 100_000 == 0 {
|
|
println!("{i}");
|
|
}
|
|
}
|
|
let mut count_list = map.into_iter().collect::<Vec<_>>();
|
|
count_list.sort();
|
|
let file = File::create("./countmap.txt")?;
|
|
let mut writer = BufWriter::new(file);
|
|
for (k, v) in count_list {
|
|
writeln!(writer, "{:02x}: {}", k, v)?;
|
|
}
|
|
Ok(())
|
|
}
|