ziggy 1.6.0

A multi-fuzzer management utility for all of your Rust fuzzing needs 🧑‍🎤
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anyhow::Result;
use std::{fs::File, hash::Hasher, io, io::Read, path::Path};

pub fn hash_file(path: &Path) -> Result<u64> {
    let mut hasher = twox_hash::XxHash64::with_seed(0);
    let mut file = File::open(path)?;

    let mut buf = [0; 8 * 1024];
    loop {
        match file.read(&mut buf) {
            Ok(0) => return Ok(hasher.finish()),
            Ok(n) => hasher.write(&buf[..n]),
            Err(e) if matches!(e.kind(), io::ErrorKind::Interrupted) => (),
            Err(e) => return Err(e.into()),
        }
    }
}