# hash-stream-validation

> Hash a stream of data, then validate

Latest version **0.2.4** (published 2020-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install hash-stream-validation
pnpm add hash-stream-validation
yarn add hash-stream-validation
bun add hash-stream-validation
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2020-08-25 |
| First published | 2015-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Stephen Sawchuk |
| Maintainers | stephenplusplus |
| Keywords | hash, stream, algorithm, validation, crc32c, crc32, md5 |

## Links

- npm: https://www.npmjs.com/package/hash-stream-validation
- Repository: https://github.com/stephenplusplus/hash-stream-validation
- Homepage: https://github.com/stephenplusplus/hash-stream-validation#readme
- Issues: https://github.com/stephenplusplus/hash-stream-validation/issues
- npm.io page: https://npm.io/package/hash-stream-validation

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.2.4 (latest) — 2020-08-25
- 0.2.3 — 2020-05-15
- 0.1.4 — 2019-10-04
- 0.2.2 — 2019-10-04
- 0.2.1 — 2016-06-07
- 0.2.0 — 2016-06-07
- 0.1.3 — 2015-11-14
- 0.1.2 — 2015-10-02
- 0.1.1 — 2015-09-27
- 0.1.0 — 2015-08-24

## README

# hash-stream-validation
> Hash a stream of data, then validate

```sh
$ npm install --save hash-stream-validation
```
```js
var hashStreamValidation = require('hash-stream-validation');

var validateStream = hashStreamValidation();

fs.createReadStream(filePath)
  .pipe(validateStream)
  .on('data', function() { /*... */ })
  .on('end', function() {
    validateStream.test('md5', /*checksum*/);
  });
```

## Do this for faster crc32c computation

If the speeds are too slow for your use, this module will `try` to require [`fast-crc32c`](http://gitnpm.com/fast-crc32c). We chose not to make it an `optionalDependency` because npm's scary warning output confuses users into thinking their hard drive was just erased.


```js
$ npm install --save fast-crc32c
```

## Use Case

After a successful upload to a Google Cloud Storage bucket, the API will respond with the hash of data it has received. During our upload, we can run the data through this module, then confirm after the upload if we both arrived at the same results. If not, we know something went wrong during the transmission.

## API

### validateStream = hashStreamValidation([opts])

#### opts.crc32c
- Type: `Boolean`
- Default: `true`

Enable crc32c hashing via [sse4_crc32](https://gitnpm.com/sse4_crc32).*

* Note: Any issues installing this module on your system should be opened at their repository.

#### opts.md5
- Type: `Boolean`
- Default: `true`

Enable MD5 hashing.

### validateStream.test(algo, sum)

#### algo
- Type: `String`

The alogrithm to test the sum against ('crc32c' or 'md5').

#### sum
- Type: `String`

The base64-encoded sum to validate.

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