3
$\begingroup$

What is the best way to convert ByteArray objects into hexadecimal string representation? Although the following works, I find it questionably awkward (and likely not very efficient):

ByteArray[{9, 182, 236, 38, 171, 0, 236, 56}] // 
 StringJoin@IntegerString[Normal@#, 16, 2] &

"09b6ec26ab00ec38"

I contrast this complication with BaseEncode which directly converts ByteArrays to Base64 encoding.

(EDIT: Sure, considering the shortness of the solution one might consider this question a sort of a thinly veiled feature request! Still, I'm curious of any better alternatives.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.