Skip to content

@technobuddha > library > Binary > Hash

Abstract Class: ShaBase

Defined in: sha-base.ts:14

The base class for sha based cryptographic hash functions

Extends

Extended by

Constructors

Constructor

ts
new ShaBase(blockSize: number, finalSize: number): ShaBase;

Defined in: src/sha-base.ts:45

Creates a new instance of the hash base class.

Parameters

ParameterTypeDescription
blockSizenumberThe size of the internal block buffer in bytes.
finalSizenumberThe size of the final hash output in bytes.

Returns

ShaBase

Overrides

HashBase.constructor

Methods

digest()

Call Signature

ts
digest(): Uint8Array;

Defined in: src/sha-base.ts:77

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

Overrides

HashBase.digest

Call Signature

ts
digest(encoding: BinaryEncoding): string;

Defined in: src/sha-base.ts:78

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.

Overrides

HashBase.digest


update()

Call Signature

ts
update(data: BinaryObject | ArrayLike<number>): this;

Defined in: src/sha-base.ts:119

Updates the hash with the given binary data.

Parameters
ParameterTypeDescription
dataBinaryObject | ArrayLike<number>The data to update the hash with, as a BinaryObject.
Returns

this

The hash instance for method chaining.

Overrides

HashBase.update

Call Signature

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

Defined in: src/sha-base.ts:120

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.

Overrides

HashBase.update