Trait HashData

Source
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()));
}

Required Methods§

Source

fn md5(&self) -> Vec<u8>

Produce an MD5 hash.

Source

fn sha1(&self) -> Vec<u8>

Produce a SHA1 hash.

Source

fn sha256(&self) -> Vec<u8>

Produce a SHA256 hash.

Implementations on Foreign Types§

Source§

impl HashData for [u8]

Source§

fn md5(&self) -> Vec<u8>

Source§

fn sha1(&self) -> Vec<u8>

Source§

fn sha256(&self) -> Vec<u8>

Implementors§

Source§

impl<T> HashData for T
where T: PE,