toHex

fun ByteArray.toHex(upperCase: Boolean = false): String

Encodes this byte array as a hexadecimal string.

Each byte produces exactly two hexadecimal digits, most significant nibble first, so the output length is always twice the input length. An empty array produces an empty string. This function never throws.

Return

the hexadecimal representation of this array.

Parameters

upperCase

when true, emits digits A to F in upper case; when false (the default), emits a to f in lower case.