Function: pseudonymize()
pseudonymize(
id,ctx):string
Replace an identifier with a consistent keyed-HMAC surrogate. The same input under the same key always yields the same surrogate (linkage preserved); the surrogate is not reversible without the key (collision-resistant, key-dependent). Domain-separated from keyedHash.
Parameters
id
string
The identifier to pseudonymize (MRN, beneficiary number, account number).
ctx
The de-identification context holding the consumer's key.
Returns
string
A lowercase-hex surrogate, consistent per (key, id).
Example
import { pseudonymize, createDeidContext } from "@cosyte/deid";
const ctx = createDeidContext({ key: "secret" });
pseudonymize("MRN-123", ctx) === pseudonymize("MRN-123", ctx); // => true (consistent)