Skip to main content
@tevm/voltaire
@tevm/voltaire / index / wasm / Sha256Wasm

Sha256Wasm

SHA256 hash function implemented using WASM Zig code

Variables

BLOCK_SIZE

const BLOCK_SIZE: 64 = 64
Defined in: src/crypto/sha256.wasm.ts:20 SHA256 block size in bytes

OUTPUT_SIZE

const OUTPUT_SIZE: 32 = 32
Defined in: src/crypto/sha256.wasm.ts:15 SHA256 output size in bytes (256 bits / 8)

Functions

create()

create(): object
Defined in: src/crypto/sha256.wasm.ts:110 Incremental hasher for streaming data Note: This implementation uses a simple buffer accumulator. For truly large streaming data, consider using the Noble.js implementation.

Returns

digest()
digest(): Uint8Array
Finalize and get hash
Returns
Uint8Array
update()
update(data): void
Update hasher with new data
Parameters
data
Uint8Array
Returns
void

Example


hash()

hash(data): Uint8Array
Defined in: src/crypto/sha256.wasm.ts:34 Compute SHA256 hash of input data

Parameters

data
Uint8Array Input data as Uint8Array

Returns

Uint8Array 32-byte hash

Example


hashHex()

hashHex(hex): Uint8Array
Defined in: src/crypto/sha256.wasm.ts:68 Compute SHA256 hash of hex string (without 0x prefix)

Parameters

hex
string Hex string (with or without 0x prefix)

Returns

Uint8Array 32-byte hash

Example


hashString()

hashString(str): Uint8Array
Defined in: src/crypto/sha256.wasm.ts:50 Compute SHA256 hash of UTF-8 string

Parameters

str
string Input string

Returns

Uint8Array 32-byte hash

Example


toHex()

toHex(hash): string
Defined in: src/crypto/sha256.wasm.ts:90 Convert hash output to hex string

Parameters

hash
Uint8Array Hash bytes

Returns

string Hex string with 0x prefix

Example