npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

crc32-js

v0.1.1

Published

A better Javascript CRC checksum or hashing implementation that yields the same result as C and PHP CRC functions

Downloads

6

Readme

CRC32 (and CRC16) in JS

A better Javascript CRC checksum or hashing implementation that yields the same result as C and PHP CRC functions.

Purpose

This package was created because other JavaScript CRC functions either tend to be inefficient, or don't match the CRC function output from implementations in C, or in PHP.

Included is a 32-bit and a 16-bit CRC (cyclic redundancy checksum) function. This function is often used to check for data integregity. It can also be used as a concise hash, however there are some chances for collision at scale.

Usage

After installing and importing the package (npm and yarn entries coming soon), it can be used as follows

crc32(str, [usePolynomialDivision], [format])

Include a string to hash, and optionally elect to use polynomial division, which is set to false by default. Instead of polynomial division, the default is to use a pre-calculated lookup table, which is faster. This is also the implementation strategy used within the C and PHP source code.

The last option defaults to true, making the output a hexadecimal value. If set to false the output will be in decimal format.

Collision resistance

CRC32 might be attractive as a hashing function because of its concise nature. However, collisions should be expected at scale. For this reason it can be used as a hashing function at small scale, or as an effective checksum function.

At first it might seem that the chance of collision is low, because CRC32 results in fixed length 32-bit values. However, the birthday paradox should be considered when checking for the probability of collision between any two values, as a set grows.

$P = 1 - \frac{k!}{k^n (k-n)!}$

where

  • n is the size of the set
  • k is the total number of possible hashes in the algorithm (2^32)
  • P is the probability of a collision

Applying this, if we have a set size of 1000 different strings, the probability of a collision between two of them is 0.01164%, or 1 in 8600. Clearly, this is a good function for checksums, but not an ideal function for most applications of hash functions.

Roadmap

Other features that are coming soon include the following:

  • Argument to toggle between CRC32a and CRC32b
  • CRC16 implementation (currently incomplete)
  • Docs that explain how CRC32 works in more detail