Standard library module for computing the CRC-32c checksum.
CRC32c.crc32c
—Functioncrc32c(data, crc::UInt32=0x00000000)
Compute the CRC-32c checksum of the givendata
, which can be anArray{UInt8}
, a contiguous subarray thereof, or aString
. Optionally, you can pass a startingcrc
integer to be mixed in with the checksum. Thecrc
parameter can be used to compute a checksum on data divided into chunks: performingcrc32c(data2, crc32c(data1))
is equivalent to the checksum of[data1; data2]
. (Technically, a little-endian checksum is computed.)
There is also a methodcrc32c(io, nb, crc)
to checksumnb
bytes from a streamio
, orcrc32c(io, crc)
to checksum all the remaining bytes. Hence you can doopen(crc32c, filename)
to checksum an entire file, orcrc32c(seekstart(buf))
to checksum anIOBuffer
without callingtake!
.
For aString
, note that the result is specific to the UTF-8 encoding (a different checksum would be obtained from a different Unicode encoding). To checksum ana::Array
of some other bitstype, you can docrc32c(reinterpret(UInt8,a))
, but note that the result may be endian-dependent.
CRC32c.crc32c
—Methodcrc32c(io::IO, [nb::Integer,] crc::UInt32=0x00000000)
Read up tonb
bytes fromio
and return the CRC-32c checksum, optionally mixed with a startingcrc
integer. Ifnb
is not supplied, thenio
will be read until the end of the stream.
Settings
This document was generated withDocumenter.jl version 1.8.0 onWednesday 9 July 2025. Using Julia version 1.11.6.