chksum 0.2.2

High-level interface for easy calculation of checksum digest for files, directories, stdin and more.
Documentation

chksum

GitHub docs.rs Coverage MSRV deps.rs unsafe forbidden LICENSE

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