crypto : Fix crash with invalid hex strings

Fixes issue #5723