# @types/sha256-wasm

> TypeScript definitions for sha256-wasm

Latest version **2.2.3** (published 2023-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/sha256-wasm
pnpm add @types/sha256-wasm
yarn add @types/sha256-wasm
bun add @types/sha256-wasm
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2023-11-21 |
| First published | 2022-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51446 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/sha256-wasm
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha256-wasm
- npm.io page: https://npm.io/package/@types/sha256-wasm

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 2.2.3 (latest) — 2023-11-21
- 2.2.0 (ts4.1) — 2022-11-08
- 2.2.2 — 2023-11-07
- 2.2.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/sha256-wasm`

# Summary
This package contains type definitions for sha256-wasm (https://github.com/chm-diederichs/sha256-wasm#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha256-wasm.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha256-wasm/index.d.ts)
````ts
/// <reference lib="dom" />
/// <reference types="node" />

export = Sha256;

/**
 * Create a new hash instance.
 */
declare function Sha256(): Sha256;

/**
 * Create a new hash instance.
 *
 * @example
 * import Sha256 = require('sha256-wasm')
 *
 * if (!Sha256.WASM_SUPPORTED) {
 *   console.log('WebAssembly not supported by your runtime')
 * }
 *
 * const hash = new Sha256()
 *   .update('hello')
 *   .update(' ')
 *   .update(Buffer.from('world'))
 *   .digest('hex')
 *
 * console.log('Sha256 hash of "hello world" is ', hash)
 * // 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
 */
declare class Sha256 {
    static readonly SHA256_BYTES: 32;
    static readonly WASM: Sha256.Wasm | false;
    static readonly WASM_SUPPORTED: boolean;

    /**
     * Wait for the WASM code to load.
     */
    static ready(cb?: (err: Error | undefined) => void): Promise<void>;

    finalized: boolean;
    digestLength: number;
    pointer: number;
    pos: number;
    /**
     * Update the hash with a new piece of data.
     *
     * @param data The data to update the hash with.
     * @param [encoding='utf-8'] The encoding of the data string.
     */
    update(data: Uint8Array | readonly number[]): this;
    update(data: string, encoding?: string): this;
    /**
     * Digest the hash.
     */
    digest<TBuf extends Uint8Array = Uint8Array>(enc?: TBuf, offset?: number): TBuf;
    digest(enc: string): string;

    /**
     * Wait for the WASM code to load.
     */
    ready(cb?: (err: Error | undefined) => void): Promise<void>;
}

declare namespace Sha256 {
    function HMAC(key: Uint8Array): HMAC;
    class HMAC {
        constructor(key: Uint8Array);
        pad: Buffer | Uint8Array;
        inner: Sha256;
        outer: Sha256;
        update(input: Uint8Array | readonly number[]): this;
        update(input: string, encoding?: string): this;
        digest<TBuf extends Uint8Array = Uint8Array>(enc?: TBuf, offset?: number): TBuf;
        digest(enc: string): string;
    }

    interface Wasm {
        memory: WebAssembly.Memory;
        sha256(ctx: number, roi: number, length: number, final: number): void;
    }
}

````

### Additional Details
 * Last updated: Mon, 20 Nov 2023 23:36:24 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [BendingBender](https://github.com/BendingBender).

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