Cyclic Checksum
===============
`(require 'make-crc)'
- Function: make-port-crc
- Function: make-port-crc degree
Returns an expression for a procedure of one argument, a port.
This procedure reads characters from the port until the end of
file and returns the integer checksum of the bytes read.
The integer DEGREE, if given, specifies the degree of the
polynomial being computed - which is also the number of bits
computed in the checksums. The default value is 32.
- Function: make-port-crc generator
The integer GENERATOR specifies the polynomial being computed.
The power of 2 generating each 1 bit is the exponent of a term of
the polynomial. The value of GENERATOR must be larger than 127.
- Function: make-port-crc degree generator
The integer GENERATOR specifies the polynomial being computed.
The power of 2 generating each 1 bit is the exponent of a term of
the polynomial. The bit at position DEGREE is implicit and should
not be part of GENERATOR. This allows systems with numbers
limited to 32 bits to calculate 32 bit checksums. The default
value of GENERATOR when DEGREE is 32 (its default) is:
(make-port-crc 32 #b00000100110000010001110110110111)
Creates a procedure to calculate the P1003.2/D11.2 (POSIX.2) 32-bit
checksum from the polynomial:
32 26 23 22 16 12 11
( x + x + x + x + x + x + x +
10 8 7 5 4 2 1
x + x + x + x + x + x + x + 1 ) mod 2
(require 'make-crc)
(define crc32 (slib:eval (make-port-crc)))
(define (file-check-sum file) (call-with-input-file file crc32))
(file-check-sum (in-vicinity (library-vicinity) "ratize.scm"))
=> 157103930