serde-hex icon indicating copy to clipboard operation
serde-hex copied to clipboard

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

Open elpiel opened this issue 5 years ago • 1 comments

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 avatar Jun 03 '19 09:06 elpiel

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

elpiel avatar Dec 30 '19 11:12 elpiel