3 unstable releases
0.2.2 | Aug 21, 2023 |
---|---|
0.2.1 | Aug 17, 2023 |
0.1.0-rc5 | Sep 4, 2022 |
0.1.0-rc4 |
|
0.0.0 |
|
#1 in #file-checksum
2,242 downloads per month
Used in 4 crates
22KB
354 lines
chksum
High-level interface for easy calculation of checksum digest for files, directories, stdin and more.
Features
- Written in pure Rust
- Easy to use interface
- No unsafe code
- Configurable via Cargo features
Setup
Add the following entry to the dependencies
section of your Cargo.toml
file:
[dependencies]
# ...
chksum = "0.2.2"
Alternatively, you can use the cargo add
subcommand:
cargo add chksum
Usage
Use chksum
function and File
as an input.
use std::fs::File;
use chksum::chksum;
use chksum::hash::SHA2_224;
let file = File::open(path)?;
let digest = chksum::<SHA2_224, _>(file)?;
assert_eq!(
digest.to_hex_lowercase(),
"a39b86d838273f5ff4879c26f85e3cb333bb44d73b24f275bad1a6c6"
);
Alternatively use ReadDir
as an input.
use std::fs::read_dir;
use chksum::chksum;
use chksum::hash::SHA2_256;
let dir = read_dir(path)?;
let digest = chksum::<SHA2_256, _>(dir)?;
assert_eq!(
digest.to_hex_lowercase(),
"5c3bfbc8614adc72d3ec0e9b15a1fd1c55cee63e34af5a4ff058eb2eef7d8482"
);
For more usage examples, refer to the documentation available at docs.rs.
Low-level interface
Check chksum-hash
for low-level interface.
License
MIT
Dependencies
~0.8–14MB
~162K SLoC