Skip to content

Instantly share code, notes, and snippets.

@jmendeth jmendeth/crc32.js
Last active Sep 23, 2019

What would you like to do?
const table = new Int32Array(256).map((_,n) => [...Array(8)]
.reduce(c => (c>>>1) ^ ((c&1) * 0xEDB88320), n))
const fn = (C, b) => (C>>>8) ^ table[(C^b) & 0xFF]
const crc = (x, seed) => ~x.reduce(fn, ~seed)
// Example:
crc( Buffer.from('Hello') ) === 0xF7D18982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.