Skip to content
node.js CRC-32C algorithm with hardware acceleration and software fallback.
JavaScript
Branch: master
Clone or download
ashi009 overhaul package (#17)
This CL updates this package completely:

- add additional files to .npmignore.
- add coveralls badge in README.
- fix lint errors in README.
- use const/let instead of vars.
- use up-to-date `TypedArray` and `Buffer` APIs.
- add curly brackets to single-line `if`/`for`.
- make the package always safe to require.
  Instead of throwing at require time, it now exports a `calculate()` that throws.
- remove `engine` requirement from `package.json`.
- replace `blanket`, `travis-conv` with `nyc` and `coveralls`.
- replace `package-lock.json` with `yarn.lock`.
- specify dev dep versions to avoid future CI failures.
- test against node 6, 8, 10 and 12 on Travis CI.
- bump to v2.0.0, as the minimal node version required is 6.
Latest commit 5b2917d Oct 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark overhaul package (#17) Oct 5, 2019
impls overhaul package (#17) Oct 5, 2019
test overhaul package (#17) Oct 5, 2019
.gitignore update .{git,npm}ignore files and bump version to 1.0.7 (#20) Oct 5, 2019
.npmignore overhaul package (#17) Oct 5, 2019
.travis.yml overhaul package (#17) Oct 5, 2019
LICENSE
README.md overhaul package (#17) Oct 5, 2019
generate-tests.js overhaul package (#17) Oct 5, 2019
loader.js overhaul package (#17) Oct 5, 2019
package.json overhaul package (#17) Oct 5, 2019
yarn.lock overhaul package (#17) Oct 5, 2019

README.md

fast-crc32c NPM version Build Status Dependency Status Coverage Status

fast-crc32c is a CRC-32C algorithm implementation for node.js, which uses hardware acceleration (via voxer/sse4_crc32 by Anand Suresh), and fallback to software implementation when hardware acceleration fails.

Performance

CRC-32C is faster then CRC-32, which could take advantage of full CPU operand register width (64bit) instead of CRC-32's 8bit.

When using hardware acceleration, CRC-32C is about 7x ~ 9x faster than software implemented CRC-32C.

Benchmark

The 3 tested implementations are:

  • sse4_crc32c Hardware accelerated CRC-32C from sse4_crc32
  • js_crc32c Javascript implemented CRC-32C
  • js_crc32 Javascript implemented CRC-32 from buffer-crc32
$ yarn run benchmark
yarn run v1.17.3
$ node benchmark
sse4_crc32c_hw for inputs 1024B x 3,210,508 ops/sec ±2.09% (87 runs sampled)
sse4_crc32c_hw for inputs 16836819B, avg 2055B x 252 ops/sec ±2.90% (79 runs sampled)
sse4_crc32c_sw for inputs 1024B x 1,358,720 ops/sec ±1.31% (89 runs sampled)
sse4_crc32c_sw for inputs 16836819B, avg 2055B x 96.41 ops/sec ±1.42% (71 runs sampled)
js_crc32c for inputs 1024B x 409,615 ops/sec ±1.46% (89 runs sampled)
js_crc32c for inputs 16836819B, avg 2055B x 26.00 ops/sec ±0.72% (47 runs sampled)
js_crc32 for inputs 1024B x 403,262 ops/sec ±1.55% (90 runs sampled)
js_crc32 for inputs 16836819B, avg 2055B x 24.82 ops/sec ±1.70% (45 runs sampled)
1024B 16836819B, avg 2055B
sse4_crc32c_hw 3,210,508 ops/sec 252 ops/sec
sse4_crc32c_sw 1,358,720 ops/sec 96.41 ops/sec
js_crc32c 409,615 ops/sec 26.00 ops/sec
js_crc32 403,262 ops/sec 24.82 ops/sec

Install

npm install fast-crc32c@^2.0.0 --save
# For node version before 6
# npm install fast-crc32c@^1.0.0 --save

Usage

var crc32 = require('fast-crc32c');
var result = crc32.calculate(data, initial);
  • data required, String|Buffer, data to digest
  • initial optional, Number, initial CRC-32C digest
You can’t perform that action at this time.