# @tadashi/hash

> Create a hash from any value

Latest version **3.0.1** (published 2023-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tadashi/hash
pnpm add @tadashi/hash
yarn add @tadashi/hash
bun add @tadashi/hash
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2023-02-15 |
| First published | 2021-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thiago Lagden |
| Maintainers | lagden |
| Keywords | key, value, hash, lib |

## Links

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

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2023-02-15
- 3.0.0 — 2022-10-30
- 2.2.0 — 2022-06-22
- 2.1.0 — 2021-08-19
- 2.0.0 — 2021-05-05
- 1.0.0 — 2021-02-24

## README

# hash

[![NPM version][npm-img]][npm]
[![Node.js CI][ci-img]][ci]
[![Coverage Status][coveralls-img]][coveralls]

[![XO code style][xo-img]][xo]


[npm-img]:         https://img.shields.io/npm/v/@tadashi/hash.svg
[npm]:             https://www.npmjs.com/package/@tadashi/hash
[ci-img]:          https://github.com/lagden/hash/actions/workflows/nodejs.yml/badge.svg
[ci]:              https://github.com/lagden/hash/actions/workflows/nodejs.yml
[coveralls-img]:   https://coveralls.io/repos/github/lagden/hash/badge.svg?branch=main
[coveralls]:       https://coveralls.io/github/lagden/hash?branch=main
[xo-img]:          https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]:              https://github.com/sindresorhus/xo


Create a hash from any data (Node.js).  
Create a hash from string (Browser).


## Install

```
$ npm i @tadashi/hash
```


## API (Node.js)

### hash(data[, options])

> Return: Buffer | string


#### data

> Type: string | Buffer | TypedArray | DataView  
> Default: - 


#### options

> Type: Object  
> Default: see below


parameter | type      | required    | default     | description
--------  | --------  | ----------- | ----------- | ------------
alg       | string    | no          | sha256      | algorithm
encoding  | string    | no          | -           | encoding of the return value


## API (Browser)

### hash(data[, options])

> Return: Promise\<string|Buffer\>


#### data

> Type: string  
> Default: - 


#### options

> Type: Object  
> Default: see below


parameter | type      | required    | default     | description
--------  | --------  | ----------- | ----------- | ------------
alg       | string    | no          | sha256      | algorithm
asBuffer  | boolean   | no          | false       | return hash as buffer


## Usage

Via Node

```js
import hash from '@tadashi/hash'

const data = hash('test', {encoding: 'hex'})
// => 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
```

Via Browser

⚠️ **Warning**

This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

```js
import hash from 'https://unpkg.com/@tadashi/hash@{version}/src/browser.js'

const data = await hash('test', {encoding: 'hex'})
// => 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
```


## License

MIT © [Thiago Lagden](https://github.com/lagden)

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