@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
updatemethods allows chaining for incremental hashing. - The
digestmethods finalize the hash computation and return the result either as aUint8Arrayor as an encoded string.
Extended by
Constructors
Constructor
new HashBase(): HashBase;Returns
HashBase
Methods
digest()
Call Signature
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
The hash digest
Call Signature
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
| Parameter | Type | Description |
|---|---|---|
encoding | BinaryEncoding | Optional. 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
abstract update(data: BinaryObject): this;Defined in: src/hash-base.ts:42
Updates the hash with the given binary data.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | BinaryObject | The data to update the hash with, as a BinaryObject. |
Returns
this
The hash instance for method chaining.
Call Signature
abstract update(data: string, encoding?: TextEncoding): this;Defined in: src/hash-base.ts:50
Updates the hash with the given string data.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | string | The string data to update the hash with. |
encoding? | TextEncoding | Optional text encoding of the input string (e.g., 'utf8'). |
Returns
this
The hash instance for method chaining.