Skip to main content
Version: v0.0.7

Function: keyedHash()

keyedHash(value, ctx): string

Replace a value with a keyed one-way digest (HMAC-SHA-256). Like pseudonymize it is consistent and non-reversible without the key, but domain-separated so it is a distinct surrogate space from pseudonyms.

Parameters

value

string

The value to hash.

ctx

DeidContext

The de-identification context holding the consumer's key.

Returns

string

A lowercase-hex keyed digest, consistent per (key, value).

Example

import { keyedHash, createDeidContext } from "@cosyte/deid";

const ctx = createDeidContext({ key: "secret" });
typeof keyedHash("value", ctx); // => "string"