# sumchecker

> Checksum validator

Latest version **3.0.1** (published 2019-11-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install sumchecker
pnpm add sumchecker
yarn add sumchecker
bun add sumchecker
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2019-11-25 |
| First published | 2016-09-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 8.0 |
| Dependencies | 1 |
| Unpacked size | 221.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Lee |
| Maintainers | malept |
| Keywords | checksum, hash |

## Links

- npm: https://www.npmjs.com/package/sumchecker
- Repository: https://github.com/malept/sumchecker
- Homepage: https://github.com/malept/sumchecker#readme
- Issues: https://github.com/malept/sumchecker/issues
- npm.io page: https://npm.io/package/sumchecker

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^4.1.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2019-11-25
- 3.0.0 — 2019-04-30
- 2.0.2 — 2017-03-11
- 1.3.1 — 2017-03-11
- 2.0.1 — 2017-01-27
- 2.0.0 — 2017-01-27
- 1.3.0 — 2016-12-06
- 1.2.0 — 2016-09-16
- 1.1.0 — 2016-09-07
- 1.0.0 — 2016-09-06

## README

# Sumchecker

[![Travis CI](https://travis-ci.org/malept/sumchecker.svg?branch=master)](https://travis-ci.org/malept/sumchecker)
[![AppVeyor CI](https://ci.appveyor.com/api/projects/status/wm4n2r11nlff8ify?svg=true)](https://ci.appveyor.com/project/malept/sumchecker)
[![Code Coverage](https://codecov.io/gh/malept/sumchecker/branch/master/graph/badge.svg)](https://codecov.io/gh/malept/sumchecker)
![Dependency Status](https://tidelift.com/badges/github/malept/sumchecker)


Sumchecker is a pure Node.js solution to validating files specified in a checksum file, which are
usually generated by programs such as [`sha256sum`](https://en.wikipedia.org/wiki/Sha256sum).

## Usage

```javascript
const sumchecker = require('sumchecker');

try {
  await sumchecker(algorithm, checksumFilename, baseDir, filesToCheck);
  console.log('All files validate!');
} catch (error) {
  console.error('An error occurred', error);
}
```

Returns a [`Promise`]. The promise is resolved when all files specified in
[`filesToCheck`](#filesToCheck) are validated. The promise is rejected otherwise.

### Parameters

#### `algorithm`

`String` - The hash algorithm used in [`checksumFilename`](#checksumFilename). Corresponds to the
algorithms allowed by [`crypto.createHash()`].

#### `checksumFilename`

`String` - The path to the checksum file.

#### `baseDir`

`String` - The base directory for the files specified in [`filesToCheck`](#filesToCheck).

#### `filesToCheck`

`Array` or `String` - one or more paths of the files that will be validated, relative to
[`baseDir`](#baseDir).

### Errors

These are `sumchecker`-specific error classes that are passed to the promise's reject callback.

#### `sumchecker.ChecksumMismatchError`

When at least one of the files does not match its expected checksum.

Properties:

* `filename` (`String`) - a path to a file that did not match

#### `sumchecker.ChecksumParseError`

When the checksum file cannot be parsed (as in, it does not match the checksum file format).

Properties:

* `lineNumber` (`Number`) - the line number that could not be parsed
* `line` (`String`) - the raw line data that could not be parsed, sans newline

#### `sumchecker.NoChecksumFoundError`

When at least one of the files specified to check is not listed in the checksum file.

Properties:

* `filename` (`String`) - a filename from [`filesToCheck`](#filesToCheck)

## Support

[Get supported sumchecker with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-sumchecker?utm_source=npm-sumchecker&utm_medium=referral&utm_campaign=readme).

## Security contact information

To report a security vulnerability, please use the [Tidelift security
contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.

## Legal

This library is copyrighted under the terms of the [Apache 2.0 License].

[`crypto.createHash()`]: https://nodejs.org/dist/latest-v4.x/docs/api/crypto.html#crypto_crypto_createhash_algorithm
[`Promise`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
[Apache 2.0 License]: http://www.apache.org/licenses/LICENSE-2.0

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