vthib/tlsh

[feature request] impl FromStr

qynybary-ryteto opened this issue · 4 comments

Is it possible to implement a impl FromStr?
I would like to be able to do something like this:

let tlsh = tlsh2::Tlsh::from_str("T184A022B383C2A2A20ACB0830880CF0202CCAC080033A023800338A30B0880AA8E0BE38"); // <<< this
let tlsh2 = tlsh2::TlshDefaultBuilder::build_from(b"odit aut fugit, sed quia consequuntur magni dolores").ok_or_else(|| "could not generate TLSH from second payload")?;
assert_eq!(tlsh.diff(&tlsh2, true), 209);

example: https://github.com/Uinelj/tlsh-rs/blob/main/src/tlsh.rs#L99-L158

++, that would be great, I also had to implement this in my fork secutils-dev/tlsh#L374-L422

vthib commented

Yes, done in #7.

I also added typedefs for the Tlsh object too. While your example works thanks to type inference due to the diff call, there are cases where it wouldn't work, and it would have been cumbersome and bug-prone to have to provide the generic values by hand.

vthib commented

The 0.3.0 release is out with those changes

Thank you @vthib for the quick turnaround on this one!