Constant time hex and base64 encode and decode