This commit is contained in:
nora 2024-06-29 16:02:35 +02:00
parent 8627450ca8
commit 6d46c730b9
2 changed files with 24 additions and 6 deletions

13
src/bin/md5sum.rs Normal file
View file

@ -0,0 +1,13 @@
fn main() {
for file in std::env::args().skip(1) {
match std::fs::read(&file) {
Err(err) => {
eprintln!("error reading {file}: {err}")
}
Ok(content) => {
let sum = crypto_hype::hashes::md5::hash(&content);
println!("{sum} {file}");
}
};
}
}

View file

@ -28,7 +28,6 @@ pub fn hash(msg: &[u8]) -> Md5Fingerprint {
};
let n = msg_pad.len() / BYTES_IN_WORD;
dbg!(&msg_pad);
// We only access msg and msg_pad through m and n now.
utils::undefine_variable!(msg);
utils::undefine_variable!(msg_pad);
@ -218,11 +217,17 @@ mod tests {
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
"57edf4a22be3c955ac49da2e2107b67a",
);
// TODO: doesn't work yet
// assert_same(
// include_str!("md5.rs"),
// "a1459b7404c1a426a759e0023460dc3d",
// );
assert_same(
"8217498327598324983271489372149837214987239847239847238947239847983247298347298347238947238947289\
3257239587348957432098574389257438957348975849357438957489357849357439857438957439857438957348957346\
289053420574238574395743298543895743890574389574398057348957348957438957439857438957438957438957438\
4290854390765493025784932574893578394758943578493574893758493758493758493574389574389573489574389574\
4290854390765493025784932574893578394758943578493574893758493758493758493574389574389573489574389574\
4290854390765493025784932574893578394758943578493574893758493758493758493574389574389573489574389574\
4290854390765493025784932574893578394758943578493574893758493758493758493574389574389573489574389574\
4290854390765493025784932574893578394758943578493574893758493758493758493574389574389573489574389574",
"63a98dcd30822c7f129b6e76d62a732d",
);
}
#[test]