Function crc64

Source
pub fn crc64(crc: u64, data: &[u8]) -> u64
Expand description

Calculate the Crc64 checksum over data, starting from crc.

use crc64::crc64;

let cksum = crc64::crc64(0, b"123456789");
assert_eq!(16845390139448941002, cksum);
Examples found in repository?
examples/crcspeed.rs (line 22)
5fn main() {
6    let args = env::args().collect::<Vec<_>>();
7    if args.len() == 1 {
8        println!("Usage: {} [list of files]", args[0]);
9        panic!();
10    }
11
12    let f = &args[1];
13    let mut crc = 0;
14    let content = fs::read(f).expect("can't read file");
15
16    let sz = content.len();
17    let size_mb = sz as f64 / 1024.0 / 1024.0;
18
19    println!("CRC for {:.2} MB file", size_mb);
20
21    let start = Instant::now();
22    crc = crc64::crc64(crc, content.as_slice());
23    let elapsed = start.elapsed();
24
25    let total_time_seconds = elapsed.as_secs();
26    let speed = size_mb / total_time_seconds as f64;
27
28    println!("{:x}  {}", crc, f);
29    println!("{} seconds at {:.2} MB/s", total_time_seconds, speed);
30}