Created
July 26, 2020 18:01
-
-
Save chadaustin/edaa1068e7a994532584be2b50bcfc2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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