有没有比下面的版本更好/更短的方法从常量十六进制创建字节数组?
byteArrayOf(0xA1.toByte(), 0x2E.toByte(), 0x38.toByte(), 0xD4.toByte(), 0x89.toByte(), 0xC3.toByte())
I tried to put 0xA1
without .toByte()
but I receive syntax error complaint saying integer literal does not conform to the expected type Byte
. Putting integer is fine but I prefer in hex form since my source is in hex string. Any hints would be greatly appreciated. Thanks!