Skip to content

Latest commit

 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI codecov

CRC32

CRC32 is a Julia package for computing the CRC-32 checksum as defined by the ISO 3309 / ITU-T V.42 / CRC-32-IEEE standards, designed as a drop-in replacement for Julia's CRC32c standard library (which computes the CRC-32c checksum). A wider variety of CRC checksum algorithms is provided by the CRC.jl package, and cryptographic checksums can be found in MD5.jl and SHA.jl.

It exports a single function, crc32, described below (analogous to CRC32c.crc32c).

The implementation uses the libdeflate_crc32 function from Eric Biggers's libdeflate library. This implementation is heavily optimized, and on x86-64 and arm64 hardware its speed is approximately on par with the CRC32c.crc32c function from the Julia standard library.

crc32(data, [crc]) and crc32(io, [crc]):

crc32(data, crc::UInt32=0x00000000)

Compute the CRC-32 checksum (ISO 3309, ITU-T V.42, CRC-32-IEEE) of the given data, which can be an Array{UInt8}, a contiguous subarray thereof, an AbstractVector{UInt8}, or a String. Optionally, you can pass a starting crc integer to be mixed in with the checksum. The crc parameter can be used to compute a checksum on data divided into chunks: performing crc32(data2, crc32(data1)) is equivalent to the checksum of [data1; data2].

There is also a method crc32(io, nb, crc) to checksum nb bytes from a stream io, or crc32(io, crc) to checksum all the remaining bytes. Hence you can do open(crc32, filename) to checksum an entire file, or crc32(seekstart(buf)) to checksum an IOBuffer without calling take!.

For a String, note that the result is specific to the UTF-8 encoding (a different checksum would be obtained from a different Unicode encoding).

Authors

Steven G. Johnson, based on API code from the Julia CRC32c standard library (also originally contributed by SGJ). The libdeflate_crc32 function was developed by Eric Biggers.

The Julia code in this package (and its antecedents in the Julia CRC32c standard library) is free/open-source software under the MIT License (see LICENSE file). The backing libdeflate library is also under MIT licence.

About

CRC32 package for Julia

Resources

Stars

6 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages