hash.ts

Hash utilities using Web Crypto API and DJB2.

Provides hash_sha256, hash_sha384, hash_sha512, hash_sha1 (Web Crypto, async) and hash_insecure (DJB2, fast non-cryptographic). For BLAKE3, see hash_blake3 in hash_blake3.ts.

Declarations
#

5 declarations

view source

hash_insecure
#

hash.ts view source

(data: string | BufferSource): string

Computes a fast non-cryptographic hash using DJB2 algorithm. Use for content comparison and cache keys, not security.

Note: Strings use UTF-16 code units, buffers use raw bytes. For non-ASCII, hash_insecure(str) !== hash_insecure(encoder.encode(str)).

data

String or binary data to hash.

type string | BufferSource

returns

string

8-character hex-encoded unsigned 32-bit hash.

hash_sha1
#

hash.ts view source

(data: string | BufferSource): Promise<string>

Computes a SHA-1 hash using Web Crypto API.

data

String or binary data to hash. Strings are UTF-8 encoded.

type string | BufferSource

returns

Promise<string>

40-character hexadecimal hash string.

hash_sha256
#

hash.ts view source

(data: string | BufferSource): Promise<string>

Computes a SHA-256 hash using Web Crypto API.

data

String or binary data to hash. Strings are UTF-8 encoded.

type string | BufferSource

returns

Promise<string>

64-character hexadecimal hash string.

hash_sha384
#

hash.ts view source

(data: string | BufferSource): Promise<string>

Computes a SHA-384 hash using Web Crypto API.

data

String or binary data to hash. Strings are UTF-8 encoded.

type string | BufferSource

returns

Promise<string>

96-character hexadecimal hash string.

hash_sha512
#

hash.ts view source

(data: string | BufferSource): Promise<string>

Computes a SHA-512 hash using Web Crypto API.

data

String or binary data to hash. Strings are UTF-8 encoded.

type string | BufferSource

returns

Promise<string>

128-character hexadecimal hash string.

Depends on
#