crc32c
1 Basic Generation
crc32c-bytes
crc32c-string/  utf8
crc32c-string/  latin-1
crc32c-string/  locale
crc32c-input-port
2 Incremental Generation
crc32c-initial-value
crc32c-update
crc32c-finalize
7.1

crc32c

Tetsumi <[email protected]>

 (require crc32c) package: crc32c

This package provides an implementation of CRC32-C.

CRC32-C is specified as the CRC that uses the iSCSI polynomial (#x1edc6f41) in RFC 3720. The polynomial was introduced by G. Castagnoli, S. Braeuer and M. Herrmann.

1 Basic Generation

procedure

(crc32c-bytes bytes)  fixnum?

  bytes : bytes?
Generates a checksum from a bytes? object.

Example:
> (crc32c-bytes #"Lorem ipsum dolor sit amet")

3993763883

procedure

(crc32c-string/utf8 string)  fixnum?

  string : string?
(crc32c-string/latin-1 string)  fixnum?
  string : string?
(crc32c-string/locale string)  fixnum?
  string : string?
Generates a checksum from a string? object.

Example:
> (crc32c-string/utf8 "Lorem ipsum dolor sit amet")

3993763883

procedure

(crc32c-input-port [in])  fixnum?

  in : input-port? = (current-input-port)
Generates a checksum reading bytes from an input-port? object.

Examples:
> (crc32c-input-port (open-input-bytes #"Lorem ipsum dolor sit amet"))

3993763883

> (crc32c-input-port (open-input-string "Lorem ipsum dolor sit amet"))

3993763883

2 Incremental Generation

The following procedures generate a checksum incrementally, one byte at a time.

value

crc32c-initial-value : fixnum? = 4294967295

Initial value to use to start the generation of a checksum.

procedure

(crc32c-update acc byte)  fixnum?

  acc : fixnum?
  byte : byte?
Returns updated acc after using byte.

Example:

procedure

(crc32c-finalize acc)  fixnum?

  acc : fixnum?
Finalizes the generation by applying the final XOR operation to acc.

Examples:
> (crc32c-finalize (crc32c-update crc32c-initial-value 123))

3127684199

> (for/fold ([acc crc32c-initial-value]
             #:result (crc32c-finalize acc))
            ([ch "Lorem ipsum dolor sit amet"])
    (crc32c-update acc (char->integer ch)))

3993763883