Skip to content

Commit 589eb5f

Browse files
committed
refactor: use sha2 directly rather than sha256
this also means we don't need to parse from hex, we can go directly to digest bytes
1 parent 73718d0 commit 589eb5f

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

Cargo.lock

Lines changed: 1 addition & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ hex = "0.4.3"
88
log = "0.4.22"
99
md5 = "0.8.0"
1010
# default "async" feature that brings in tokio
11-
sha256 = { version = "1.5.0", default-features = false }
11+
sha2 = "0.10.8"
1212
thiserror = "2.0.0"
1313
sha1 = "0.10.6"
1414
hmac = "0.12.1"

src/openssl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::aes;
22
use crate::common::DecryptError;
33
use log::warn;
4+
use sha2::Digest;
45

56
/// The type of hash to use when generating a key/iv pair from a passphrase
67
#[derive(Clone, Debug)]
@@ -24,8 +25,7 @@ struct OpenSSLCryptInfo {
2425

2526
/// Returns the SHA256 hash of the provided data
2627
fn sha256_digest(data: &[u8]) -> Vec<u8> {
27-
// This *should* never fail
28-
hex::decode(sha256::digest(data)).expect("Failed to decode SHA256 hash")
28+
sha2::Sha256::digest(data).to_vec()
2929
}
3030

3131
/// Returns the MD5 hash of the provided data

0 commit comments

Comments
 (0)