Skip to content

newHash

newHash(name: string, data?: string | Uint8Array<ArrayBufferLike>): HashObject

Defined in: packages/pythonlib/src/hashlib.ts:170

Create a new hash object for the given algorithm.

Parameters

ParameterTypeDescription
namestringName of the hash algorithm (e.g., “sha256”, “md5”)
data?string | Uint8Array<ArrayBufferLike>Optional initial data to hash

Returns

HashObject

A hash object

Example

const h = newHash("sha256")
h.update("hello")
console.log(await h.hexdigest())