4

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.)

kirma
  • 19,056
  • 1
  • 51
  • 93

0 Answers0