buffer-crc32
crc32 that works with binary data and fancy character sets, outputs buffer, signed or unsigned data and has tests.
Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix
install
npm install buffer-crc32
example
var crc32 = ;// works with buffersvar buf = // -> <Buffer 94 5a ab 4a> // has convenience methods for getting signed or unsigned intscrc32 // -> -1805997238crc32 // -> 2488970058 // will cast to buffer if given a string, so you can// directly use foreign characters safely // -> <Buffer cb 03 1a c5> // and works in append mode toovar partialCrc = ;var partialCrc = ;var partialCrc = ;var partialCrc = ;var finalCrc = ; // -> <Buffer 47 fa 55 70>
tests
This was tested against the output of zlib's crc32 method. You can run
the tests withnpm test
(requires tap)
see also
https://github.com/alexgorbatchev/node-crc, crc.buffer.crc32
also
supports buffer inputs and return unsigned ints (thanks @tjholowaychuk).
license
MIT/X11