@types/sha512-wasm
TypeScript icon, indicating that this package has built-in type declarations

2.3.3 • Public • Published

Installation

npm install --save @types/sha512-wasm

Summary

This package contains type definitions for sha512-wasm (https://github.com/chm-diederichs/sha512-wasm#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha512-wasm.

index.d.ts

/// <reference lib="dom" />
/// <reference types="node" />

export = Sha512;

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

/**
 * Create a new hash instance.
 *
 * @example
 * import Sha512 = require('sha512-wasm')
 *
 * if (!Sha512.WASM_SUPPORTED) {
 *   console.log('WebAssembly not supported by your runtime')
 * }
 *
 * const hash = new Sha512()
 *   .update('hello')
 *   .update(' ')
 *   .update(Buffer.from('world'))
 *   .digest('hex')
 *
 * console.log('Sha512 hash of "hello world" is ', hash)
 * // 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
 */
declare class Sha512 {
    static readonly SHA512_BYTES: 64;
    static readonly WASM: Sha512.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;
    wasm: Sha512.Wasm | false;
    /**
     * 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 Sha512 {
    function HMAC(key: Uint8Array): HMAC;
    class HMAC {
        constructor(key: Uint8Array);
        pad: Buffer | Uint8Array;
        inner: Sha512;
        outer: Sha512;
        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;
        sha512(ctx: number, roi: number, length: number, final: number): void;
    }
}

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: @types/node

Credits

These definitions were written by BendingBender.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/sha512-wasm

Weekly Downloads

9

Version

2.3.3

License

MIT

Unpacked Size

7.17 kB

Total Files

5

Last publish

Collaborators

  • types