chore: format code

This commit is contained in:
Michel de Graaf
2025-07-31 22:00:06 +02:00
parent 6431630510
commit 843fb79d59
21 changed files with 421 additions and 238 deletions
+13 -8
View File
@@ -54,8 +54,9 @@ fn i(x: u32, y: u32, z: u32) -> u32 {
// utility function to convert a vector of type T with size N into an array of type T with size N.
fn vec_to_array<T, const N: usize>(v: Vec<T>) -> [T; N] {
v.try_into()
.unwrap_or_else(|_v: Vec<T>| panic!("error converting vector to array - sizes don't match"))
v.try_into().unwrap_or_else(|_v: Vec<T>| {
panic!("error converting vector to array - sizes don't match")
})
}
/**
@@ -297,14 +298,16 @@ fn compute_md5_digest(mut v: Vec<u8>) -> String {
let word_dd = word_d;
// execute round 1
let result = round_one_operations(word_a, word_b, word_c, word_d, &table, &x);
let result =
round_one_operations(word_a, word_b, word_c, word_d, &table, &x);
word_a = result[0];
word_b = result[1];
word_c = result[2];
word_d = result[3];
// execute round 2
let result = round_two_operations(word_a, word_b, word_c, word_d, &table, &x);
let result =
round_two_operations(word_a, word_b, word_c, word_d, &table, &x);
word_a = result[0];
word_b = result[1];
@@ -312,14 +315,16 @@ fn compute_md5_digest(mut v: Vec<u8>) -> String {
word_d = result[3];
// execute round 3
let result = round_three_operations(word_a, word_b, word_c, word_d, &table, &x);
let result =
round_three_operations(word_a, word_b, word_c, word_d, &table, &x);
word_a = result[0];
word_b = result[1];
word_c = result[2];
word_d = result[3];
// execute round 4
let result = round_four_operations(word_a, word_b, word_c, word_d, &table, &x);
let result =
round_four_operations(word_a, word_b, word_c, word_d, &table, &x);
word_a = result[0];
word_b = result[1];
word_c = result[2];
@@ -374,7 +379,6 @@ fn bit_padding(input: &str) -> Vec<u8> {
}
fn split_u64_to_u8_array(s: u64) -> [u8; 8] {
[
s as u8,
(s >> 8) as u8,
@@ -455,7 +459,8 @@ fn lowercase_alphabet_correct_hash() {
#[test]
fn all_alphanumeric_correct_hash() {
let alpha_num_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let alpha_num_str =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
assert_eq!("d174ab98d277d9f5a5611c2c9f419d9f", md5(alpha_num_str));
}