Skip to content

Instantly share code, notes, and snippets.

function crc32(s/*, polynomial = 0x04C11DB7, initialValue = 0xFFFFFFFF, finalXORValue = 0xFFFFFFFF*/) {
s = String(s);
var polynomial = arguments.length < 2 ? 0x04C11DB7 : arguments[1],
initialValue = arguments.length < 3 ? 0xFFFFFFFF : arguments[2],
finalXORValue = arguments.length < 4 ? 0xFFFFFFFF : arguments[3],
crc = initialValue,
table = [], i, j, c;
function reverse(x, n) {
var b = 0;