Skip to content

@technobuddha > library > Binary > Hash

Abstract Class: HashBase

Defined in: hash-base.ts:19

Abstract base class for hash algorithm implementations.

Provides a standard interface for updating hash state with data and retrieving the final digest in various formats. Concrete subclasses must implement the update and digest methods according to the specifics of the hash algorithm.

Remarks

  • The update methods allows chaining for incremental hashing.
  • The digest methods finalize the hash computation and return the result either as a Uint8Array or as an encoded string.

Extended by

Constructors

Constructor

ts
new HashBase(): HashBase;

Returns

HashBase

Methods

digest()

Call Signature

ts
abstract digest(): Uint8Array;

Defined in: src/hash-base.ts:27

Finalizes the hash computation and returns the resulting hash digest. This method performs any necessary padding and processes the final block of data according to the hash algorithm's specification.

Returns

Uint8Array

The hash digest

Call Signature

ts
abstract digest(encoding: BinaryEncoding): string;

Defined in: src/hash-base.ts:35

Finalizes the hash computation and returns the resulting hash digest. This method performs any necessary padding and processes the final block of data according to the hash algorithm's specification.

Parameters
ParameterTypeDescription
encodingBinaryEncodingOptional. The encoding to use for the output digest (e.g., 'hex', 'base64').
Returns

string

An encoded string, depending on the encoding parameter.


update()

Call Signature

ts
abstract update(data: BinaryObject): this;

Defined in: src/hash-base.ts:42

Updates the hash with the given binary data.

Parameters
ParameterTypeDescription
dataBinaryObjectThe data to update the hash with, as a BinaryObject.
Returns

this

The hash instance for method chaining.

Call Signature

ts
abstract update(data: string, encoding?: TextEncoding): this;

Defined in: src/hash-base.ts:50

Updates the hash with the given string data.

Parameters
ParameterTypeDescription
datastringThe string data to update the hash with.
encoding?TextEncodingOptional text encoding of the input string (e.g., 'utf8').
Returns

this

The hash instance for method chaining.