marcinmoskala
06/19/2017, 2:05 PMprivate val hexArray = CharArray(16) { if (it < 10) '0' + it else 'a' + (it - 10) }
fun ByteArray.toHexString(): String {
val builder = StringBuilder(size * 2)
for (byte in this) {
val v = byte.toInt() and 0xFF
builder.append(hexArray[v.ushr(4)])
builder.append(hexArray[v and 0x0F])
}
return builder.toString()
}
Implementation a bit slower, but multiplatform