ez-hash
Ergonomic hashing helpers for Rust.
- Single, simple API: each hash algorithm is a single function.
- Supports hashing either a single value or multiple parts by implementing
Hashable. - Common hash algorithms behind Cargo features (default: all enabled).
Installation
[]
= "1.0"
To enable only selected algorithms:
= { = "1.0", = false, = ["sha2", "sha3"] }
Usage
Single-part:
use sha256;
let digest = sha256;
Multi-part (tuple / array / vec):
use ;
let a = sha256;
let b = sha256;
let c = keccak256;
assert_eq!;
Bytes:
use sha256;
let bytes = 1u32.to_le_bytes;
let digest = sha256;
API
The crate exposes:
Hashabletrait (implemented for common byte/string types and for tuples/arrays/vectors of hashables)
Hash functions (availability depends on enabled features):
- SHA1:
sha1 - SHA2:
sha224,sha256,sha384,sha512,sha512_224,sha512_256 - SHA3:
sha3_224,sha3_256,sha3_384,sha3_512 - Keccak:
keccak256,keccak512 - Blake2:
blake2b_256,blake2b_384,blake2b_512,blake2s_128,blake2s_256 - Blake3:
blake3 - MD5:
md5
License
Licensed under the Apache License, Version 2.0. See LICENSE.