hello folks. Can anyone help me with CRC32 calcula...
# multiplatform
f
hello folks. Can anyone help me with CRC32 calculation in common code??? Please, more details in 🧵
In common code I have the following expect function
Copy code
expect fun calcCRC32(input: ByteArray): Long
And android code:
Copy code
actual fun calcCRC32(input : ByteArray) : Long {
    val crc32 = CRC32()
    crc32.update(input)
    return crc32.value
}
I am facing troubles to implement in ios code:
Copy code
actual fun calcCRC32(input: ByteArray): Long {

    return crc32(0, inp, input.size.toUInt()).toLong()

//    fun crc32(crc: platform.zlib.uLong /* = kotlin.ULong */,
//              buf: kotlinx.cinterop.CValuesRef<platform.zlib.uBytefVar /* = kotlinx.cinterop.UByteVarOf<kotlin.UByte> */>?,
//              len: platform.zlib.uInt /* = kotlin.UInt */): platform.zlib.uLong /* = kotlin.ULong */ { /* compiled code */ }

}
The buffer is kotlinx.cinterop.UByteVarOf<kotlin.UByte> type. How can I transform the byteArray for this type?
186 Views