Skip to content
0

katanakit-js / useHash

Function: useHash() ​

ts
function 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 ​

ParameterTypeDescription
plainTextstringThe text to hash.
salt?stringOptional 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 ​

ts
import { useHash } from "katanakit-js";

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

Released under the MIT License.