1
0
Fork 0
mirror of https://codeberg.org/ral/rwedid.git synced 2024-08-16 09:59:49 +02:00
This commit is contained in:
Ral 2023-07-21 01:53:54 +02:00
parent 5091123905
commit fcd239a3f7

View file

@ -1,4 +1,4 @@
// Compute and check the checksum over the bytes of a block.
// Compute the checksum over the bytes of a block.
pub fn checksum(bytes: &[u8]) -> u8 {
bytes.iter().fold(0u32, |x, y| x + (*y as u32)) as u8
}
@ -8,7 +8,7 @@ pub fn valid_checksum(bytes: &[u8]) -> bool {
checksum(bytes) == 0x00
}
// Print the checksum to stdout
// Print the checksum to stderr
pub fn print_checksum(bytes: &[u8]) {
let cs = checksum(bytes);
eprintln!(" Checksum is: {cs}");