Crypto Wasm
    Preparing search index...

    Class WasmAccelerator

    WebAssembly cryptographic accelerator.

    When the WASM module is available, routes heavy operations through near-native WASM code. Falls back transparently to the JavaScript implementation when WASM is not loaded.

    Auto-detection: crypto-lib checks for this package at import time. If installed, heavy operations are automatically routed through WASM.

    import { WasmAccelerator } from "@aspect/crypto-wasm";

    const accel = new WasmAccelerator();
    await accel.init();
    console.log(accel.isAvailable); // true if WASM loaded
    const digest = await accel.hash("sha256", new Uint8Array([1, 2, 3]));
    accel.destroy();
    Index
    • get isAvailable(): boolean

      Check if WASM acceleration is available.

      Returns boolean

    • get wasmModule(): Module | null

      The compiled WebAssembly module, or null if not loaded.

      Returns Module | null

    • Initialize the WASM module from a .wasm file or buffer.

      Parameters

      • OptionalwasmSource: BufferSource | Response

      Returns Promise<void>

    • Hash data using WASM-accelerated implementation. Falls back to JS.

      Parameters

      • algorithm: string

        Hash algorithm name (e.g. "sha256", "sha512", "blake3").

      • data: Uint8Array

        Raw bytes to hash.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The hash digest as a Uint8Array.

    • Reset the accelerator, releasing the WASM module.

      Returns void