Skip to content

Commit

Permalink
feat(storage): add sha256 hash computation util
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Mar 3, 2023
1 parent ce5d622 commit ada8714
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contracts/cw-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ cw2.workspace = true
schemars.workspace = true
serde.workspace = true
thiserror.workspace = true
sha2 = "0.10.6"
base16ct = "0.1.1"

[dev-dependencies]
cw-multi-test.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions contracts/cw-storage/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use sha2::{Sha256, Digest};

pub fn sha256_hash(data: &Vec<u8>) -> String {
base16ct::lower::encode_string(&Sha256::digest(data))
}
1 change: 1 addition & 0 deletions contracts/cw-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ pub mod contract;
mod error;
pub mod msg;
pub mod state;
pub mod crypto;

pub use crate::error::ContractError;

0 comments on commit ada8714

Please sign in to comment.