pub trait HashData {
// Required methods
fn md5(&self) -> Vec<u8> ⓘ;
fn sha1(&self) -> Vec<u8> ⓘ;
fn sha256(&self) -> Vec<u8> ⓘ;
}
Expand description
Syntactic sugar for producing various hashes of data. Typically applied to [u8]
slices.
§Example
use hex;
use exe::{HashData, PE, VecPE};
use exe::types::CCharString;
let pefile = VecPE::from_disk_file("test/compiled.exe").unwrap();
let section_table = pefile.get_section_table().unwrap();
println!("=Section Hashes=");
for section in section_table {
println!("[{}]", section.name.as_str().unwrap());
let section_data = section.read(&pefile).unwrap();
println!("MD5: {}", hex::encode(section_data.md5()));
println!("SHA1: {}", hex::encode(section_data.sha1()));
println!("SHA256: {}\n", hex::encode(section_data.sha256()));
}