From c949570b1e40b8a2e279c62a975f64e1784dda3c Mon Sep 17 00:00:00 2001 From: KCarretto Date: Wed, 21 Feb 2024 01:25:29 +0000 Subject: [PATCH] enable hashing binary files --- implants/lib/eldritch/src/crypto/hash_file_impl.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/implants/lib/eldritch/src/crypto/hash_file_impl.rs b/implants/lib/eldritch/src/crypto/hash_file_impl.rs index 52f8e3642..02e919b55 100644 --- a/implants/lib/eldritch/src/crypto/hash_file_impl.rs +++ b/implants/lib/eldritch/src/crypto/hash_file_impl.rs @@ -7,10 +7,9 @@ use sha2::{Sha256, Sha512}; use anyhow::{anyhow, Result}; pub fn hash_file(file: String, algo: String) -> Result { - let mut file_data = String::new(); - File::open(file)?.read_to_string(&mut file_data)?; + let mut file_data = std::fs::read(file)?; match algo.to_lowercase().as_str() { - "md5" => Ok(format!("{:02x}", md5::compute(file_data.as_bytes()))), + "md5" => Ok(format!("{:02x}", md5::compute(file_data))), "sha1" => { let mut hasher = Sha1::new(); hasher.update(&file_data);