checksums 0.9.1

Tool for making/verifying checksums of directory trees
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::io::{BufReader, Read};
use self::super::hash_string;


// Pseudocode: https://en.wikipedia.org/wiki/Longitudinal_redundancy_check
pub fn hash<R: Read>(reader: &mut R) -> String {
    let mut lrc = 0u16;
    for b in BufReader::new(reader).bytes() {
        lrc = (lrc + b.unwrap() as u16) & 0xFF;
    }
    let lrc = (((lrc ^ 0xFF) + 1) & 0xFF) as u8;

    hash_string(&[lrc])
}