diff --git a/Cargo.toml b/Cargo.toml index 2886df5..538dada 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptohelpers" -version = "1.7.0" +version = "1.7.1" license= "MIT" description = "Collection of helpers and simplifying functions for cryptography things" authors = ["Avril "] diff --git a/src/sha256.rs b/src/sha256.rs index 0431590..2c9513f 100644 --- a/src/sha256.rs +++ b/src/sha256.rs @@ -122,6 +122,21 @@ where T: AsyncRead + Unpin + ?Sized } +/// Compute SHA256 hash from an iterator of slices. +pub fn compute_slice_iter(from: I) -> Sha256Hash +where T: AsRef<[u8]>, + I: IntoIterator +{ + let mut hasher = Sha256::new(); + for from in from.into_iter() + { + hasher.update(from.as_ref()); + } + + let mut hash = [0u8; SIZE]; + bytes::copy_slice(&mut hash, &hasher.finalize()); + Sha256Hash{hash} +} /// Compute SHA256 hash from a slice. pub fn compute_slice(from: T) -> Sha256Hash where T: AsRef<[u8]>