# node-sha1

> Exports a SHA1 function that uses node's crpyto module under the hood

Latest version **1.0.1** (published 2015-09-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-sha1
pnpm add node-sha1
yarn add node-sha1
bun add node-sha1
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-09-11 |
| First published | 2013-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Michael Leaney |
| Maintainers | leahcimic |
| Keywords | sha1, crypto, hash, digest, stream, buffer, string |

## Links

- npm: https://www.npmjs.com/package/node-sha1
- Repository: https://github.com/leahciMic/node-sha1
- Homepage: https://github.com/leahciMic/node-sha1#readme
- Issues: https://github.com/leahciMic/node-sha1/issues
- npm.io page: https://npm.io/package/node-sha1

## 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

- 1.0.1 (latest) — 2015-09-11
- 1.0.0 — 2015-09-11
- 0.0.2 — 2015-09-11
- 0.0.1 — 2013-08-23

## README

# node-sha1 [![Build Status](https://travis-ci.org/leahciMic/node-sha1.svg?branch=master)](https://travis-ci.org/leahciMic/node-sha1)

Provides you with a convenient sha1 function that uses Node's crypto module
under the hood.

## Install
`npm install node-sha1 --save`

## Usage
```javascript
var sha1 = require('node-sha1');
sha1('Hello World!'); # 2ef7bde608ce5404e97d5f042f95f89f1c232871
```

## API

`sha1(what, callback)`

### what

Can be a string, buffer, or even a stream (stream requires a callback).

If what is a string, or a buffer the hash will be returned, if a callback
is registered it will also be called with the resulting hash.

If what is a stream, it will throw if a callback is not registered. Otherwise
it will call the callback with the resulting hash.

### callback(err, hash)

`err` any errors that occurred, or undefined if no errors occurred. `hash` is
the resulting hash. If a callback is registered it will be called with the
resulting hash regardless if a stream, string, or buffer is used.

## Examples

### Use with strings

```js
var sha1 = require('node-sha1');
sha1('Hello World!'); # 2ef7bde608ce5404e97d5f042f95f89f1c232871
```

### Use with buffers

```js
var sha1 = require('node-sha1');
var buffer = new Buffer('Hello World!');
sha1(buffer); # 2ef7bde608ce5404e97d5f042f95f89f1c232871
```

### Use with streams

```js
var sha1 = require('node-sha1');

util.inherits(FakeStream, stream.Readable);

function FakeStream() {
  this._finished = false;
  stream.Readable.call(this);
}

FakeStream.prototype._read = function() {
  if (this._finished) {
    this.push(null);
    return;
  }
  this._finished = true;
  this.push('Hello World!');
};

var fakeStream = new FakeStream();
sha1(fakeStream, function(err, hash) {
  # hash = 2ef7bde608ce5404e97d5f042f95f89f1c232871
})
```

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