diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2020-11-30 12:58:44 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2020-11-30 12:58:44 +0100 |
| commit | 678d45e7ae09510796d27a80ecd894f6a1ad8279 (patch) | |
| tree | 56e9dc6cc093faadd86da1edebc76334c00b6a74 /src/hash.rs | |
| parent | bd7a6880f5dce74fd154f593a5a5f7034affeee4 (diff) | |
generate random mnemonic
Diffstat (limited to 'src/hash.rs')
| -rw-r--r-- | src/hash.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hash.rs b/src/hash.rs new file mode 100644 index 0000000..6382a7a --- /dev/null +++ b/src/hash.rs @@ -0,0 +1,10 @@ +//! Module implementing various hashing utilities. + +use sha2::{Digest, Sha256}; + +/// Returns the SHA256 hash of the specified input. +pub fn sha256(data: impl AsRef<[u8]>) -> [u8; 32] { + let mut hasher = Sha256::new(); + hasher.update(data.as_ref()); + hasher.finalize().into() +} |
