use openssl for faster hashing

This commit is contained in:
Dietmar Maurer 2018-12-22 14:31:59 +01:00
parent e95950e40a
commit 7b2b40a893
2 changed files with 8 additions and 8 deletions

View File

@ -24,10 +24,9 @@ http = "0.1.13"
hyper = "0.12.14"
lazy_static = "1.1.0"
regex = "1.0.6"
rust-crypto = "0.2.36"
libc = "0.2"
nix = "0.12.0"
shellwords = "1.0.0"
uuid = { version = "0.7", features = ["v4"] }
chrono = "0.4.6" # Date and time library for Rust
openssl = "0.10.16"

View File

@ -3,8 +3,7 @@ use std::path::{Path, PathBuf};
use std::io::Write;
use std::time::Duration;
use crypto::digest::Digest;
use crypto::sha2::Sha512Trunc256;
use openssl::sha;
use std::sync::Mutex;
use std::fs::File;
@ -218,11 +217,13 @@ impl ChunkStore {
}
pub fn insert_chunk(&self, chunk: &[u8]) -> Result<(bool, [u8; 32]), Error> {
let mut hasher = Sha512Trunc256::new();
hasher.input(chunk);
let mut digest = [0u8; 32];
hasher.result(&mut digest);
// fixme: use Sha512/256 when available
let mut hasher = sha::Sha256::new();
hasher.update(chunk);
let digest = hasher.finish();
//println!("DIGEST {}", digest_to_hex(&digest));
let mut chunk_path = self.chunk_dir.clone();