Closed baloo closed 1 year ago
Alternative to #358
This removes the digest dependency and allows to implement hashing like:
digest
trait AuthenticodeDigest { /// [`authenticode_digest`] returns the result of the provided hash algorithm. fn authenticode_digest<D: Digest>(&self) -> Output<D>; } impl AuthenticodeDigest for PE<'_> { fn authenticode_digest<D: Digest>(&self) -> Output<D> { let mut digest = D::new(); for chunk in self.authenticode_ranges() { digest.update(chunk); } digest.finalize() } } fn main() { let mut buf = Vec::new(); let mut f = File::open("/nix/store/bhsxra1hc7yhja2kzw5rdds90i3w3a54-linux-5.10.147/bzImage").unwrap(); f.read_to_end(&mut buf).unwrap(); let pe = PE::parse(&buf).unwrap(); let hash = pe.authenticode_digest::<Sha256>(); println!("hash: {:x?}", hash); }
anything missing or can we merge as this?
This is great @baloo sorry for delay and thanks for making these changes!
non-breaking
released in 0.7.0, thank you so much for your patience!
Alternative to #358
This removes the
digest
dependency and allows to implement hashing like: