Skip to content

Commit 1dee549

Browse files
[bcr-ebill-core] remove sha2 and reuse bitcoin::hashes
1 parent 46c00a7 commit 1dee549

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

crates/bcr-ebill-core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ serde_repr.workspace = true
1515
chrono.workspace = true
1616
uuid.workspace = true
1717
log.workspace = true
18-
sha2.workspace = true
1918
thiserror.workspace = true
2019
bitcoin.workspace = true
2120
bip39.workspace = true

crates/bcr-ebill-core/src/util/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ pub mod date;
33

44
pub use crypto::BcrKeys;
55

6-
use sha2::{Digest, Sha256};
6+
use bitcoin::hashes::sha256;
7+
use bitcoin::hashes::Hash;
78
use thiserror::Error;
89
use uuid::Uuid;
910

@@ -12,10 +13,8 @@ pub fn get_uuid_v4() -> Uuid {
1213
}
1314

1415
pub fn sha256_hash(bytes: &[u8]) -> String {
15-
let mut hasher = Sha256::new();
16-
hasher.update(bytes);
17-
let hash = hasher.finalize();
18-
base58_encode(&hash)
16+
let hash = sha256::Hash::hash(bytes).to_byte_array();
17+
base58_encode(hash.as_slice())
1918
}
2019

2120
#[derive(Debug, Error)]

0 commit comments

Comments
 (0)