mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 15:46:53 +00:00
remove openssl dep
This commit is contained in:
@@ -49,7 +49,7 @@ use crate::{
|
||||
store_init::{load_format_erasure, ErasureError},
|
||||
utils::{
|
||||
self,
|
||||
crypto::{base64_decode, base64_encode, hex, sha256},
|
||||
crypto::{base64_decode, base64_encode, hex},
|
||||
path::{encode_dir_object, has_suffix, SLASH_SEPARATOR},
|
||||
},
|
||||
xhttp,
|
||||
@@ -540,7 +540,9 @@ impl SetDisks {
|
||||
|
||||
fn get_multipart_sha_dir(bucket: &str, object: &str) -> String {
|
||||
let path = format!("{}/{}", bucket, object);
|
||||
hex(sha256(path.as_bytes()).as_ref())
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(path);
|
||||
hex(hasher.finalize())
|
||||
}
|
||||
|
||||
fn common_parity(parities: &[i32], default_parity_count: i32) -> i32 {
|
||||
|
||||
+12
-12
@@ -10,16 +10,16 @@ pub fn hex(data: impl AsRef<[u8]>) -> String {
|
||||
hex_simd::encode_to_string(data, hex_simd::AsciiCase::Lower)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn sha256(data: &[u8]) -> impl AsRef<[u8; 32]> {
|
||||
use sha2::{Digest, Sha256};
|
||||
<Sha256 as Digest>::digest(data)
|
||||
}
|
||||
// #[cfg(windows)]
|
||||
// pub fn sha256(data: &[u8]) -> impl AsRef<[u8; 32]> {
|
||||
// use sha2::{Digest, Sha256};
|
||||
// <Sha256 as Digest>::digest(data)
|
||||
// }
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn sha256(data: &[u8]) -> impl AsRef<[u8]> {
|
||||
use openssl::hash::{Hasher, MessageDigest};
|
||||
let mut h = Hasher::new(MessageDigest::sha256()).unwrap();
|
||||
h.update(data).unwrap();
|
||||
h.finish().unwrap()
|
||||
}
|
||||
// #[cfg(not(windows))]
|
||||
// pub fn sha256(data: &[u8]) -> impl AsRef<[u8]> {
|
||||
// use openssl::hash::{Hasher, MessageDigest};
|
||||
// let mut h = Hasher::new(MessageDigest::sha256()).unwrap();
|
||||
// h.update(data).unwrap();
|
||||
// h.finish().unwrap()
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user