# @cumulus/checksum

> Cumulus checksum utilities

Latest version **22.4.0** (published 2026-09-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @cumulus/checksum
pnpm add @cumulus/checksum
yarn add @cumulus/checksum
bun add @cumulus/checksum
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 22.4.0 |
| Published | 2026-09-02 |
| First published | 2019-02-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 304 |
| Author | Cumulus Authors |
| Maintainers | cumuluspublisher, nsidc_kovarik, jennyhliu, npauzenga, ppilone84, etcart |
| Keywords | CUMULUS |

## Links

- npm: https://www.npmjs.com/package/@cumulus/checksum
- Repository: https://github.com/nasa/cumulus
- Homepage: https://github.com/nasa/cumulus/tree/master/packages/checksum/README.md
- Issues: https://github.com/nasa/cumulus/issues
- npm.io page: https://npm.io/package/@cumulus/checksum

## Recent versions

- 22.4.0 (latest) — 2026-09-02
- 21.3.5 (release-v21.3.5) — 2026-06-03
- 20.3.3 (release-v20.3.3) — 2026-04-16
- 21.2.1 (release-v21.2.1) — 2026-03-18
- 21.3.2-testlerna.0 (release-v21.3.2-testlerna.0) — 2026-03-02
- 21.3.1-alpha.0 (release-v21.3.1-alpha.0) — 2026-01-28
- 20.3.2 (release-v20.3.2) — 2025-12-04
- 20.2.3 (release-v20.2.3) — 2025-12-03
- 21.0.0-echo10 (release-v21.0.0-echo10) — 2025-11-21
- 20.3.1 (release-v20.3.1) — 2025-10-14
- 20.2.2 (release-v20.2.2) — 2025-10-08
- 20.1.3-alpha.2 (release-v20.1.3-alpha.2) — 2025-05-15
- 20.1.3-alpha.1 (release-v20.1.3-alpha.1) — 2025-05-15
- 20.1.3-alpha.0 (release-v20.1.3-alpha.0) — 2025-05-14
- 18.5.6 (release-v18.5.6) — 2025-04-11
- … 185 more at https://npm.io/package/@cumulus/checksum/versions

## README

# @cumulus/checksum

## Checksum

The `@cumulus/checksum` library provides checksum functionality used by Cumulus
packages and tasks. Currently the supported input includes file streams, and
supported checksum algorithms include `cksum` and the algorithms available to
the `crypto` package, as documented
[here](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options).

## Usage

```js
const fs = require('fs');
const { generateChecksumFromStream } = require('@cumulus/checksum');

const stream = fs.createReadStream('myDataFile.hdf');
const myCksum = generateChecksumFromStream('cksum', stream);
```

## API

<a name="module_checksum"></a>

## checksum

* [checksum](#module_checksum)
    * [.generateChecksumFromStream(algorithm, stream, [options])](#module_checksum.generateChecksumFromStream) ⇒ <code>Promise.&lt;(number\|string)&gt;</code>
    * [.validateChecksumFromStream(algorithm, stream, expectedSum, [options])](#module_checksum.validateChecksumFromStream) ⇒ <code>Promise.&lt;boolean&gt;</code>

<a name="module_checksum.generateChecksumFromStream"></a>

### checksum.generateChecksumFromStream(algorithm, stream, [options]) ⇒ <code>Promise.&lt;(number\|string)&gt;</code>
Create <algorithm> file checksum from readable stream

**Kind**: static method of [<code>checksum</code>](#module_checksum)
**Returns**: <code>Promise.&lt;(number\|string)&gt;</code> - the file checksum

| Param | Type | Description |
| --- | --- | --- |
| algorithm | <code>string</code> | Checksum algorithm type |
| stream | <code>stream.Readable</code> | A readable file stream |
| [options] | <code>Object</code> | Checksum options, see `crypto.createHash()` |

<a name="module_checksum.validateChecksumFromStream"></a>

### checksum.validateChecksumFromStream(algorithm, stream, expectedSum, [options]) ⇒ <code>Promise.&lt;boolean&gt;</code>
Validate expected checksum against calculated checksum

**Kind**: static method of [<code>checksum</code>](#module_checksum)
**Returns**: <code>Promise.&lt;boolean&gt;</code> - whether expectedSum === calculatedSum

| Param | Type | Description |
| --- | --- | --- |
| algorithm | <code>string</code> | Checksum algorithm |
| stream | <code>stream.Readable</code> | A readable file stream |
| expectedSum | <code>number</code> \| <code>string</code> | expected checksum |
| [options] | <code>Object</code> | Checksum options |


## About Cumulus

Cumulus is a cloud-based data ingest, archive, distribution and management
prototype for NASA's future Earth science data streams.

[Cumulus Documentation](https://nasa.github.io/cumulus)

---
Generated automatically using `npm run build-docs`

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