Saltar al contenido principal

Function: useHash()

useHash(plainText, salt?): Promise<string>

Defined in: src/core/services/generator.service.ts:196

Derives a PBKDF2-SHA512 hash of plainText. Returns "salt:hashHex". Prefer a unique salt per secret.

Parameters

plainText

string

The text to hash.

salt?

string

Optional hex salt. When omitted a random 16-byte salt is generated.

Returns

Promise<string>

"salt:hashHex" — the salt and the 128-char hex digest joined by a colon.

Example

import { useHash } from "katanakit-js";

const digest = await useHash("secret", "optional-salt");
// => "optional-salt:<128 hex chars>"