* Compute the crc32 of a string. * This is almost the same as the function crc32, but for strings. Using the * same function for the two use cases leads to horrible performances. * @param {Number} crc the starting value of the crc. * @param {String} str the string to use. * @param {Number} len
(crc, str, len, pos)
| 528 | * @return {Number} the computed crc32. |
| 529 | */ |
| 530 | function crc32str(crc, str, len, pos) { |
| 531 | var t = crcTable, end = pos + len; |
| 532 | |
| 533 | crc = crc ^ (-1); |
| 534 | |
| 535 | for (var i = pos; i < end; i++ ) { |
| 536 | crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF]; |
| 537 | } |
| 538 | |
| 539 | return (crc ^ (-1)); // >>> 0; |
| 540 | } |
| 541 | |
| 542 | module.exports = function crc32wrapper(input, crc) { |
| 543 | if (typeof input === "undefined" || !input.length) { |