#sha-256 #hash #stream #async #data-structures

async-hash

Traits and helper functions for SHA256 hashing of async data types

10 releases

0.5.3 Dec 20, 2023
0.5.2 Nov 6, 2023
0.5.1 Sep 3, 2023
0.5.0 Jul 3, 2023
0.1.0 Dec 20, 2021

#403 in Cryptography

Download history 11/week @ 2023-12-30 18/week @ 2024-01-06 30/week @ 2024-01-13 32/week @ 2024-01-20 40/week @ 2024-01-27 20/week @ 2024-02-03 13/week @ 2024-02-10 61/week @ 2024-02-17 33/week @ 2024-02-24 39/week @ 2024-03-02 50/week @ 2024-03-09 41/week @ 2024-03-16 59/week @ 2024-03-23 102/week @ 2024-03-30 34/week @ 2024-04-06 37/week @ 2024-04-13

233 downloads per month
Used in 17 crates (13 directly)

Apache-2.0

12KB
287 lines

async-hash

A Rust library for SHA256 hashing of data structures which only support async access


lib.rs:

Provides traits Hash, HashStream, and HashTryStream for SHA-2 hashing data which must be accessed asynchronously, e.g. a Stream or database table.

Hash is implemented for standard Rust types:

  • Primitive types:
    • bool
    • i8, i16, i32, i64, i128, isize
    • u8, u16, u32, u64, u128, usize
    • f32, f64
    • &str
    • String
  • Common standard library types:
    • Option<T>
    • PhantomData<T>
  • Compound types:
    • [T; 0] through [T; 32]
    • tuples up to size 16
  • Collection types:
    • BTreeMap<K, V>
    • BTreeSet<T>
    • BinaryHeap<T>
    • LinkedList<T>
    • VecDeque<T>
    • Vec<T>
  • Other types:
    • SmallVec<V> (requires the smallvec feature flag)

IMPORTANT: hashing is order-dependent. Do not implement the traits in this crate for any data structure which does not have a consistent order. Consider using the collate crate if you need to use a type which does not implement [Ord].

Dependencies

~1–1.4MB
~28K SLoC