encoder and decoder now support extendable formats.
This commit is contained in:
1 parent
6e65a216c5
commit
63b231975b
13 files changed
+288
-23
No files matched your search
@@ -11,6 +11,16 @@ fun longToBytes(value: Long): ByteArray {
|
||||
return result
|
||||
}
|
||||
|
||||
fun intToBytes(value: Int): ByteArray {
|
||||
var l = value
|
||||
val result = ByteArray(8)
|
||||
for (i in 3 downTo 0) {
|
||||
result[i] = (l and 0xFF).toByte()
|
||||
l = l shr 8
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 8 bytes to LE long
|
||||
*/
|
||||
@@ -23,6 +33,15 @@ fun bytesToLong(b: ByteArray): Long {
|
||||
return result
|
||||
}
|
||||
|
||||
fun bytesToInt(b: ByteArray): Int {
|
||||
var result: Int = 0
|
||||
for (i in 0 until 4) {
|
||||
result = result shl 8
|
||||
result = result or (b[i].toInt() and 0xFF)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
private val hexDigits = "0123456789ABCDEF"
|
||||
|
||||
|
||||
Reference in new issue
Block a user