If I had to deal with Long I’d create the following extension:
fun Long.toByteArray(): ByteArray {
val buffer = ByteBuffer.allocate(Long.SIZE_BYTES)
buffer.putLong(this)
return buffer.array()
}
I wonder what the proper way to convert usigned int and long to big endian in this case since ByteBuffer obviously don’t accept them.