CRC32

class CRC32 : Checksum

A Kotlin common implementation of CRC32.

The algorithm uses a precomputed table (with polynomial 0xEDB88320) and:

  • Initializes crc to 0xFFFFFFFF (i.e. -1)

  • For each byte, updates: crc = table(crc xor byte) & 0xFF xor (crc ushr 8)

  • When getValue() is called, returns (crc xor 0xFFFFFFFF) masked to 32 bits.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun getValue(): Long

Returns the current CRC32 value.

Link copied to clipboard
open override fun reset()

Resets the CRC32 checksum to its initial value.

Link copied to clipboard
open override fun update(b: Int)

Updates the CRC32 checksum with the specified byte. Only the low 8 bits of b are used.

open override fun update(b: ByteArray, off: Int, len: Int)

Updates the CRC32 checksum with the specified array of bytes.

open fun update(b: ByteArray)

Updates the current checksum with the specified array of bytes.

open fun update(buffer: Buffer)

Updates the current checksum with the bytes from the specified buffer.

open fun update(byteBuffer: ByteBuffer)