# @wmhilton/crypto-hash

> Tiny hashing module that uses the native crypto API in Node.js and the browser

Latest version **1.0.2** (published 2018-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wmhilton/crypto-hash
pnpm add @wmhilton/crypto-hash
yarn add @wmhilton/crypto-hash
bun add @wmhilton/crypto-hash
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-11-22 |
| First published | 2018-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 645 |
| Author | Sindre Sorhus |
| Maintainers | wmhilton |
| Keywords | crypto, hash, isomorphic, hashing, hasher, cryptography, sha1, sha256, sha384, sha512, browser |

## Links

- npm: https://www.npmjs.com/package/@wmhilton/crypto-hash
- Repository: https://github.com/sindresorhus/crypto-hash
- Homepage: https://github.com/sindresorhus/crypto-hash#readme
- Issues: https://github.com/sindresorhus/crypto-hash/issues
- npm.io page: https://npm.io/package/@wmhilton/crypto-hash

## 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.2 (latest) — 2018-11-22
- 1.0.1 — 2018-11-22

## README

# crypto-hash [![Build Status](https://travis-ci.org/sindresorhus/crypto-hash.svg?branch=master)](https://travis-ci.org/sindresorhus/crypto-hash)

> Tiny hashing module that uses the native crypto API in Node.js and the browser

Useful when you want the same hashing API in all environments. My cat calls it *isomorphic*.

In Node.js it uses [`require('crypto')`](https://nodejs.org/api/crypto.html#crypto_class_hash), while in the browser it uses [`window.crypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest).

The browser version is only ~300 bytes minified & gzipped.


## Install

```
$ npm install crypto-hash
```

<a href="https://www.patreon.com/sindresorhus">
	<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>


## Usage

```js
const {sha256} = require('crypto-hash');

(async () => {
	console.log(await sha256('🦄'));
	//=> '5df82936cbf0864be4b7ba801bee392457fde9e4'
})();
```


## API

### sha1(input, [options])
### sha256(input, [options])
### sha384(input, [options])
### sha512(input, [options])

Returns a `Promise<string>` with a hex-encoded hash.

*Note that even though it returns a promise, [in Node.js, the operation is synchronous 💩](https://github.com/nodejs/node/issues/678).*

[SHA-1 is insecure](https://stackoverflow.com/a/38045085/64949) and should not be used for anything sensitive.

#### input

Type: `string` [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView)

#### options

Type: `Object`

##### outputFormat

Type: `string`<br>
Values: `hex` `buffer`<br>
Default: `hex`

Setting this to `buffer` makes it return an `ArrayBuffer` instead of a `string`.


## Related

- [hasha](https://github.com/sindresorhus/hasha) - Hashing in Node.js made simple


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

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