libhasher
A library for hashing text and files
Basic usage
Hashing Text
use libhasher::Hasher;
fn main() {
let mut hasher = Hasher::new("sha256").unwrap();
println!("{}", hasher.hash_text("Hello, World!").unwrap());
}
Hashing a File
With a progress bar
The progress bar will show on files >= 256MB in size
use libhasher::Hasher;
use std::path::PathBuf;
fn main() {
let mut hasher = Hasher::new("blake3").unwrap();
let progress = true
let mmap = false; let result = hasher.hash_file_progressbar(&PathBuf::from("very_large.file"), progress, mmap, None).unwrap();
println!("{}", result.hash);
}
Without a progress bar
use libhasher::Hasher;
use std::path::PathBuf;
fn main() {
let mut hasher = Hasher::new("sha256").unwrap();
let mmap = true; let result = hasher.hash_file(&PathBuf::from("Cargo.toml"), mmap).unwrap();
println!("{}", result.hash);
}