SheetJS/js-crc32 là dự án mã nguồn mở trên GitHub với 351 sao, viết chủ yếu bằng Python. :cyclone: JS standard CRC-32 and CRC32C implementation
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/SheetJS/js-crc32 là nguồn chính thức.
SheetJS/js-crc32 có phải mã nguồn mở không?
Có — SheetJS/js-crc32 phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/SheetJS/js-crc32.
SheetJS/js-crc32 có trang demo không?
Dự án có trang chủ ở http://oss.sheetjs.com/js-crc32/. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
SheetJS/js-crc32 dùng license gì?
SheetJS/js-crc32 phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
SheetJS/js-crc32 là gì?
SheetJS/js-crc32 (SheetJS/js-crc32) là dự án Python trên GitHub. Theo mô tả gốc: :cyclone: JS standard CRC-32 and CRC32C implementation
Đọc đầy đủ README ở tab phía trên.
js-crc32 có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về js-crc32.