351 GitHub stars and counting — SheetJS/js-crc32 is a Python project TopGit is tracking across repositories on the platform. :cyclone: JS standard CRC-32 and CRC32C implementation
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
In the browser, the crc32.js script can be loaded directly:
<script src="crc32.js"></script>
The browser script exposes a variable CRC32.
The script will manipulate module.exports if available . This is not always
desirable. To prevent the behavior, define DO_NOT_EXPORT_CRC.
CRC32C (Castagnoli)
The module and CDNs also include a parallel script for CRC32C calculations.
Using NodeJS or a bundler:
var CRC32C = require("crc-32/crc32c");
Using NodeJS or a bundler with import:
import { bstr, buf, str } from "crc-32/crc32c";
In the browser, the crc32c.js script can be loaded directly:
<script src="crc32c.js"></script>
The browser exposes a variable CRC32C.
The script will manipulate module.exports if available . This is not always
desirable. To prevent the behavior, define DO_NOT_EXPORT_CRC.
Usage
In all cases, the relevant function takes an argument representing data and an
optional second argument representing the starting "seed" (for rolling CRC).
The return value is a signed 32-bit integer!
CRC32.buf(byte array or buffer[, seed]) assumes the argument is a sequence
of 8-bit unsigned integers (nodejs Buffer, Uint8Array or array of bytes).
CRC32.bstr(binary string[, seed]) assumes the argument is a binary string
where byte i is the low byte of the UCS-2 char: str.charCodeAt(i) & 0xFF
CRC32.str(string[, seed]) assumes the argument is a standard JS string and
calculates the hash of the UTF-8 encoding.
This does not apply to browser Buffer shims, and thus is not implemented in
the library directly.
Signed Integers
Unconventional for a CRC32 checksum, this library uses signed 32-bit integers.
This is for performance reasons. Standard JS operators can convert between
signed and unsigned 32-bit integers:
x >>> 0 converts a number value to unsigned 32-bit integer.
x | 0 converts a number value to signed 32-bit integer.
Testing
make test will run the nodejs-based test.
To run the in-browser tests, run a local server and go to the ctest directory.
make ctestserv will start a python SimpleHTTPServer server on port 8000.
To update the browser artifacts, run make ctest.
To generate the bits file, use the crc32 function from python zlib:
>>> from zlib import crc32
>>> x="foo bar baz٪☃🍣"
>>> crc32(x)
1531648243
>>> crc32(x+x)
-218791105
>>> crc32(x+x+x)
1834240887
The included crc32.njs script can process files or standard input:
$ echo "this is a test" > t.txt
$ bin/crc32.njs t.txt
1912935186
For comparison, the included crc32.py script uses python zlib:
$ bin/crc32.py t.txt
1912935186
On OSX the command cksum generates unsigned CRC-32 with Algorithm 3:
Yes — SheetJS/js-crc32 ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/SheetJS/js-crc32.
What is SheetJS/js-crc32?
SheetJS/js-crc32 (SheetJS/js-crc32) is a Python project on GitHub. From the project's own README: :cyclone: JS standard CRC-32 and CRC32C implementation
What license does SheetJS/js-crc32 use?
SheetJS/js-crc32 is released under the Apache-2.0 license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where can I see SheetJS/js-crc32 in action?
The project maintains a homepage at http://oss.sheetjs.com/js-crc32/. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about SheetJS/js-crc32?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/SheetJS/js-crc32 is the definitive source.
Read full README in the tab above.
Still deciding about js-crc32?
One click hands the question to an AI along with this page — see what it says about js-crc32.