https://github.com/stream-utils/hash-stream
Get a hash of a file or a stream
https://github.com/stream-utils/hash-stream
Last synced: 6 months ago
JSON representation
Get a hash of a file or a stream
- Host: GitHub
- URL: https://github.com/stream-utils/hash-stream
- Owner: stream-utils
- License: mit
- Created: 2013-10-03T05:00:14.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-03-03T22:05:24.000Z (almost 9 years ago)
- Last Synced: 2025-06-10T04:08:48.487Z (7 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# Hash Stream
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
Simple wrapper around `crypto.createHash()` for files and streams.
## Installation
```shell
$ npm install hash-stream
```
## API
```js
var getHash = require('hash-stream')
```
## getHash(filename || stream, algorithm, callback)
- `filename` - path of the file
- `stream` - a readable stream
- `algorithm` - any defined by `crypto.getHashes()`
Returns a `hash` as a raw `Buffer`, so if you want a hex:
```js
getHash('image.png', 'sha256', function (err, hash) {
hash = hash.toString('hex')
})
```
## [CLI](http://en.wikipedia.org/wiki/Command-line_interface)
You can use `nhash` to hash a file and get the output instantly. The usage options are simple:
```
$ nhash --help
Usage: nhash [options] [file]
Options:
-h, --help output usage information
-V, --version output the version number
-a, --algorithm the hash alorithm
-e, --encoding the encoding of output
```
[npm-image]: https://img.shields.io/npm/v/hash-stream.svg?style=flat-square
[npm-url]: https://npmjs.org/package/hash-stream
[github-tag]: http://img.shields.io/github/tag/stream-utils/hash-stream.svg?style=flat-square
[github-url]: https://github.com/stream-utils/hash-stream/tags
[travis-image]: https://img.shields.io/travis/stream-utils/hash-stream.svg?style=flat-square
[travis-url]: https://travis-ci.org/stream-utils/hash-stream
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/hash-stream.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/stream-utils/hash-stream
[david-image]: http://img.shields.io/david/stream-utils/hash-stream.svg?style=flat-square
[david-url]: https://david-dm.org/stream-utils/hash-stream
[license-image]: http://img.shields.io/npm/l/hash-stream.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/hash-stream.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/hash-stream