can anyone help in this output is different? swift...
# ktor
a
can anyone help in this output is different? swift data vs byte array
Copy code
// SWIFT
val deviceID = 116170158
*let* deviceIdData = withUnsafeBytes(of: &deviceId) { Data($0) }
print("PAYLOAD",formattedString)
output:
[174, 157, 236, 6]
Copy code
// KOTLIN
val deviceID =  116170158
val deviceIdData = ByteBuffer.allocate(Int.SIZE_BYTES)
.order(ByteOrder._LITTLE_ENDIAN_)
.putInt(deviceId.toInt())
.array()
_print_("PAYLOAD BYTEARRY: ${Arrays.toString(payload)}")
output:
[-82, -99, -20, 6]
s
Looks like it's the same data, the Kotlin version is just printing it as if it was signed
If you actually need to output the unsigned bytes you could turn it into a
UByteArray
first
otherwise don't worry; it's working fine
🙌 1
a
@Sam thanks, the whole process is send this deviceId to embeded system through encryption this devices id actually works on swift code for some reason and dosnt on android side p.s auth key is works fine on both data gets encrypted right and sent xD