Crate chksum_hash
source ·Expand description
Simple cryptography library that provides interface for calculating both batch and stream computation of hash digest.
Setup
Update your Cargo.toml
by adding entry to dependencies
section.
[dependencies]
# ...
chksum-hash = "0.2.1"
Alternatively use cargo add
subcommand.
cargo add chksum-hash
Usage example
use chksum_hash as hash;
let digest = hash::new(hash::Algorithm::SHA2_256)
.update("some")
.update(b"data")
.update([0, 1, 2, 3])
.digest();
assert_eq!(
digest.to_hex_lowercase(),
"5c3bfbc8614adc72d3ec0e9b15a1fd1c55cee63e34af5a4ff058eb2eef7d8482"
);
Feature flags
Algorithms
md5
: Enables MD5 hash algorithm.sha1
: Enables SHA-1 hash algorithm.sha2
: Enables SHA-2 hash family algorithms.sha2-224
: Enables only SHA-2 224 hash algorithm.sha2-256
: Enables only SHA-2 256 hash algorithm.sha2-384
: Enables only SHA-2 384 hash algorithm.sha2-512
: Enables only SHA-2 512 hash algorithm.
By default all of them are enabled.
Compilation
error
: AddsError
related implementations.
By default all of them are enabled.
License
MIT
Modules
md5
md5
Implementation of MD5 hash function based on RFC 1321: The MD5 Message-Digest Algorithm.
sha1
sha1
Implementation of SHA-1 hash function based on RFC 3174: US Secure Hash Algorithm 1 (SHA1).
sha2
sha2-224
or sha2-256
or sha2-384
or sha2-512
Implementation of SHA-2 hash functions family based on FIPS PUB 180-4: Secure Hash Standard.
Enums
Represents hash algorithm.
Represents hash digest.
Error
error
A common error type for the current crate.
Represents finalized state.
Represents in-progress hash state.