# sha

> Check and get file hashes

Latest version **3.0.0** (published 2019-01-23) · (BSD-2-Clause OR MIT) license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-01-23 |
| First published | 2013-04-27 |
| Weekly downloads | 0 |
| License | (BSD-2-Clause OR MIT) |
| TypeScript types | separate (@types/sha) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Maintainers | forbeslindesay, kenan, thefourtheye |

## Links

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

## Dependencies (1)

- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.2

## Recent versions

- 3.0.0 (latest) — 2019-01-23
- 2.0.1 — 2015-09-11
- 2.0.0 — 2015-09-06
- 1.3.0 — 2014-09-14
- 1.2.4 — 2014-06-06
- 1.2.3 — 2013-08-21
- 1.2.2 — 2013-08-18
- 1.2.1 — 2013-07-22
- 1.2.0 — 2013-07-07
- 1.1.0 — 2013-06-25
- 1.0.1 — 2013-04-28
- 1.0.0 — 2013-04-27

## README

# sha

Check and get file hashes (using any algorithm)

[![Build Status](https://img.shields.io/travis/ForbesLindesay/sha/master.svg)](https://travis-ci.org/ForbesLindesay/sha)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/sha.svg)](https://david-dm.org/ForbesLindesay/sha)
[![NPM version](https://img.shields.io/npm/v/sha.svg)](https://www.npmjs.com/package/sha)

## Installation

    $ npm install sha

## API

### check(fileName, expected, [options,] cb) / checkSync(filename, expected, [options])

Asynchronously check that `fileName` has a "hash" of `expected`.  The callback will be called with either `null` or an error (indicating that they did not match).

Options:

- algorithm: defaults to `sha1` and can be any of the algorithms supported by `crypto.createHash`

### get(fileName, [options,] cb) / getSync(filename, [options])

Asynchronously get the "hash" of `fileName`.  The callback will be called with an optional `error` object and the (lower cased) hex digest of the hash.

Options:

- algorithm: defaults to `sha1` and can be any of the algorithms supported by `crypto.createHash`

### stream(expected, [options])

Check the hash of a stream without ever buffering it.  This is a pass through stream so you can do things like:

```js
fs.createReadStream('src')
  .pipe(sha.stream('expected'))
  .pipe(fs.createWriteStream('dest'))
```

`dest` will be a complete copy of `src` and an error will be emitted if the hash did not match `'expected'`.

Options:

- algorithm: defaults to `sha1` and can be any of the algorithms supported by `crypto.createHash`

## License

You may use this software under the BSD or MIT.  Take your pick.  If you want me to release it under another license, open a pull request.

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