Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created July 26, 2020 18:01
Show Gist options
  • Save chadaustin/edaa1068e7a994532584be2b50bcfc2c to your computer and use it in GitHub Desktop.
Save chadaustin/edaa1068e7a994532584be2b50bcfc2c to your computer and use it in GitHub Desktop.
fn imagehash(path: &Path) -> std::io::Result<Digest> {
let mut f = File::open(path)?;
let mut buffer = [0u8; 1024*1024];
let mut context = Context::new();
loop {
let read = f.read(&mut buffer)?;
if 0 == read {
return Ok(context.compute());
}
context.consume(&buffer[0..read]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment