Kotlin Convert ByteArray to Hex String

April 8, 2019
val bytes = ...
val hex = joinToString("") { "%02x".format(bytes) }

Kotlin extension

fun ByteArray.toHex(): String {
    return joinToString("") { "%02x".format(it) }
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.