# sha512-wasm

> sha512 hashing algorithm implemented in WebAssembly

Latest version **2.3.4** (published 2022-03-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install sha512-wasm
pnpm add sha512-wasm
yarn add sha512-wasm
bun add sha512-wasm
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.4 |
| Published | 2022-03-24 |
| First published | 2019-11-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/sha512-wasm) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Christophe Diederichs |
| Maintainers | chm-diederichs |
| Keywords | sha512, WASM, WebAssembly |

## Links

- npm: https://www.npmjs.com/package/sha512-wasm
- Repository: https://github.com/chm-diederichs/sha512-wasm
- Homepage: https://github.com/chm-diederichs/sha512-wasm#readme
- Issues: https://github.com/chm-diederichs/sha512-wasm/issues
- npm.io page: https://npm.io/package/sha512-wasm

## Dependencies (2)

- [b4a](https://npm.io/package/b4a.md) ^1.0.1
- [nanoassert](https://npm.io/package/nanoassert.md) ^2.0.0

## Recent versions

- 2.3.4 (latest) — 2022-03-24
- 2.3.3 — 2021-11-23
- 2.3.2 — 2021-10-25
- 2.3.1 — 2021-04-28
- 2.3.0 — 2021-04-28
- 2.2.0 — 2021-04-28
- 2.1.1 — 2020-09-04
- 2.1.0 — 2020-09-03
- 2.0.3 — 2020-07-02
- 2.0.2 — 2020-07-02
- 2.0.1 — 2020-07-02
- 2.0.0 — 2020-07-02
- 1.2.0 — 2020-06-18
- 1.1.1 — 2020-04-06
- 1.1.0 — 2020-02-18
- … 5 more at https://npm.io/package/sha512-wasm/versions

## README

# sha512-wasm
## Usage
```js
const sha512 = require('sha512-wasm')

if (!Sha512.SUPPORTED) {
  console.log('WebAssembly not supported by your runtime')
}

var hash = sha512()
  .update('hello')
  .update(' ')
  .update(Buffer.from('world'))
  .digest('hex')

console.log('Sha512 hash of "hello world" is ', hash)
// 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
```

## API
#### `const hash = sha512()`

Create a new hash instance.

#### `hash.update(data, [enc])`

Update the hash with a new piece of data. `data` may be passed as a buffer, uint8array or a string. If `data` is passed as a string, then it will be interpreted as a `utf8` string unless `enc` specifies an encoding.

Supported `enc`s are:
- `utf8` / `utf-8` (defualt)
- `hex`
- `base64`

#### `hash.digest([enc])`

Digest the hash. If `enc` is specified, then the digest shall be returned as an `enc` encoded string. Otherwise a buffer is returned.

Supported `enc`s are:
- `utf8` / `utf-8` (defualt)
- `hex`
- `base64`

#### `var promise = sha512.ready([cb])`

Wait for the WASM code to load. Returns the WebAssembly instance promise as well for convenience.
You have to call this at least once before instantiating the hash.

## Contributing

The bulk of this module is implemented in WebAssembly in the [sha512.wat](sha512.wat) file. To build the thin Javascript wrapper do:

 ```
 npm run compile
 ```

## License

MIT

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