(digits: &[u8])
| 69 | } |
| 70 | |
| 71 | fn nib_to_byte_array(digits: &[u8]) -> Vec<u8> { |
| 72 | let mut msg_bytes = Vec::with_capacity(digits.len() / 2); |
| 73 | |
| 74 | for nibble_pair in digits.chunks(2) { |
| 75 | let byte = (nibble_pair[0] << 4) | (nibble_pair[1] & 0b00001111); |
| 76 | msg_bytes.push(byte); |
| 77 | } |
| 78 | |
| 79 | fn le_to_be_byte_array(byte_array: Vec<u8>) -> Vec<u8> { |
| 80 | assert!( |
| 81 | byte_array.len() % 4 == 0, |
| 82 | "Byte array length must be a multiple of 4" |
| 83 | ); |
| 84 | byte_array |
| 85 | .chunks(4) // Process each group of 4 bytes (one u32) |
| 86 | .flat_map(|chunk| chunk.iter().rev().cloned()) // Reverse each chunk |
| 87 | .collect() |
| 88 | } |
| 89 | le_to_be_byte_array(msg_bytes) |
| 90 | } |
| 91 | |
| 92 | fn replace_first_n_with_zero(hex_string: &str, n: usize) -> String { |
| 93 | let mut result = String::new(); |
no test coverage detected