Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
crc-32
Advanced tools
Package description
The crc-32 npm package is a JavaScript library for calculating CRC32 checksums. CRC32 is a checksum algorithm that generates a 32-bit hash of data, which can be used to verify the integrity of data during transmission or storage. This package provides functions to compute CRC32 checksums for strings and byte arrays.
CRC32 checksum from a string
This feature allows you to compute the CRC32 checksum of a given string. The 'crc32.str' function takes a string as input and returns the checksum as a signed 32-bit integer.
"use strict";
var crc32 = require('crc-32');
var str = 'Hello World';
var checksum = crc32.str(str);
console.log('Checksum for string:', checksum);
CRC32 checksum from a byte array
This feature allows you to compute the CRC32 checksum of a byte array. The 'crc32.buf' function takes a byte array (Uint8Array) as input and returns the checksum as a signed 32-bit integer.
"use strict";
var crc32 = require('crc-32');
var buf = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);
var checksum = crc32.buf(buf);
console.log('Checksum for byte array:', checksum);
The 'crc' npm package is similar to 'crc-32' and provides CRC checksum calculation for multiple CRC algorithms, including CRC32. It offers a wider range of CRC algorithms compared to 'crc-32', which is focused solely on CRC32.
The 'buffer-crc32' npm package is another alternative that provides CRC32 checksum calculation. It is designed to work with Node.js buffers and can be used to append the checksum to the buffer. It is similar to 'crc-32' but with a focus on Node.js buffer compatibility.
Readme
Standard CRC-32 algorithm implementation in JS (for the browser and nodejs). Emphasis on correctness and performance.
In nodejs:
npm install crc-32
In the browser:
<script lang="javascript" src="crc32.js"></script>
The browser exposes a variable CRC32
CRC32.buf(byte array or buffer)
assumes the argument is a set of 8 bit
unsigned integers (e.g. nodejs Buffer
or simple array of ints)
CRC32.bstr(binary string)
interprets the argument as a binary string where
the i
-th byte is str.charCodeAt(i)
CRC32.str(string)
interprets the argument as a standard JS string
make test
will run the nodejs-based test. To run the in-browser tests, run a
local server and go to the ctest
directory. To update the browser artifacts,
run make ctest
.
make perf
will run algorithmic performance tests (which should justify certain
decisions in the code).
make perf-all
compares the performance of various crc-32 algorithms that
implement the correct form (note that the SSE intrinsic is designed for the
CRC32C checksum and uses a different polynomial).
Unexpected code patterns were based on performance testing in node and browser:
Specifying an arbitrary initial CRC value
Supporting different polynomials (e.g. CRC32C)
Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 license are reserved by the Original Author.
FAQs
Pure-JS CRC-32
The npm package crc-32 receives a total of 7,380,841 weekly downloads. As such, crc-32 popularity was classified as popular.
We found that crc-32 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.