Surprisingly (to me), this code does not do what I want:
fun ByteArray.toHexString() : String {
return this.joinToString("") { it.toString(16) }
}
Turns out Byte is signed, so you get negative hex representations for individual bytes, which leads to a completely bogus end result.
Also, Byte.toString won't pad leading zeroes, which you'd want here.
What is the simplest (no additional libraries, ideally no extensions) resp. most efficient fix?