# buffer-crc32

> A pure javascript CRC32 algorithm that plays nice with binary data

Latest version **1.0.0** (published 2024-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install buffer-crc32
pnpm add buffer-crc32
yarn add buffer-crc32
bun add buffer-crc32
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-02-06 |
| First published | 2012-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 100 |
| Author | Brian J. Brennan |
| Maintainers | brianloveswords, kibertoad |

## Links

- npm: https://www.npmjs.com/package/buffer-crc32
- Repository: https://github.com/brianloveswords/buffer-crc32
- Issues: https://github.com/brianloveswords/buffer-crc32/issues
- npm.io page: https://npm.io/package/buffer-crc32

## Recent versions

- 1.0.0 (latest) — 2024-02-06
- 1.0.0-RC9 (next) — 2024-02-02
- 1.0.0-RC8 — 2024-02-02
- 1.0.0-RC7 — 2024-02-02
- 1.0.0-RC5 — 2024-02-02
- 1.0.0-RC4 — 2024-02-02
- 1.0.0-RC3 — 2024-02-02
- 1.0.0-RC2 — 2024-02-02
- 1.0.0-RC1 — 2024-02-02
- 0.2.13 — 2016-11-22
- 0.2.12 — 2016-11-21
- 0.2.11 — 2016-11-21
- 0.2.10 — 2016-11-21
- 0.2.9 — 2016-11-21
- 0.2.8 — 2016-11-21
- … 9 more at https://npm.io/package/buffer-crc32/versions

## README

# buffer-crc32

[![NPM Version](https://img.shields.io/npm/v/buffer-crc32.svg)](https://npmjs.org/package/buffer-crc32)
[![Build Status](https://github.com/brianloveswords/buffer-crc32/actions/workflows/ci.yml/badge.svg)](https://github.com/brianloveswords/buffer-crc32/actions/workflows/ci.yml)

crc32 that works with binary data and fancy character sets, outputs
buffer, signed or unsigned data and has tests.

Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix

This package requires Node 8+ to work.

# install

```
npm install buffer-crc32
```

# example

```js
const crc32 = require('buffer-crc32');
// works with buffers
const buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]);
crc32(buf); // -> <Buffer 94 5a ab 4a>

// has convenience methods for getting signed or unsigned ints
crc32.signed(buf); // -> -1805997238
crc32.unsigned(buf); // -> 2488970058

// will cast to buffer if given a string, so you can
// directly use foreign characters safely
crc32('自動販売機'); // -> <Buffer cb 03 1a c5>

// and works in append mode too
const partialCrc = crc32('hey');
const partialCrc = crc32(' ', partialCrc);
const partialCrc = crc32('sup', partialCrc);
const partialCrc = crc32(' ', partialCrc);
const finalCrc = crc32('bros', partialCrc); // -> <Buffer 47 fa 55 70>
```

# tests

This was tested against the output of zlib's crc32 method. You can run
the tests with`npm test` (requires tap)

# see also

https://github.com/alexgorbatchev/node-crc, `crc.buffer.crc32` also
supports buffer inputs and return unsigned ints (thanks @tjholowaychuk).

# license

MIT/X11

---
_Source: https://npm.io/package/buffer-crc32 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
