fspmarshall / serde-hex

Rust crate for easy serialization/deserialization of hexadecimal values.
Other
29 stars 9 forks source link

`from_hex` doesn't error when it reads from larger hex string #6

Open elpiel opened 5 years ago

elpiel commented 5 years ago

I was wondering isn't it better for this to error? Although the hex string is valid, it's 33 bytes when decoded. Currently it just cut's the last byte.

let bytes: [u8; 32] = SerdeHex::<StrictPfx>::from_hex("0x06061d5e2a67d0a9a10f1c732bca12a676d83f79663a396f7d87b3e30b9b411088");

PS: If I try 31 bytes, it gives me expected buff size '2' got '1', maybe better error handling here as well?

elpiel commented 4 years ago

@fspmarshall any update on that? I tried looking into it during the holidays, but I am not sure exactly how to achieve it.