crc32

fun crc32(bytes: ByteArray): Long

Computes the CRC-32 checksum of the given bytes.

This is the IEEE 802.3 variant (reflected polynomial 0xEDB88320, initial value 0xFFFFFFFF, final xor 0xFFFFFFFF), the same algorithm used by zip and PNG. The unsigned 32-bit result is returned in the low 32 bits of a Long, so the value is always in the range 0..4294967295 and never negative. An empty array hashes to 0. This function never throws.

CRC-32 is a non-cryptographic checksum intended for error detection. It must not be used for security purposes such as integrity against tampering.

Return

the CRC-32 value as an unsigned quantity in a Long.

Parameters

bytes

the input to checksum.


Computes the CRC-32 checksum of this string encoded as UTF-8.

The string is first converted to its UTF-8 bytes and then hashed with crc32, so all documentation of that function applies. An empty string hashes to 0. This function never throws.

Return

the CRC-32 value as an unsigned quantity in a Long.