Skip to main content
Rehydration is the process of replacing placeholder tags with original values.

rehydrate()

Replaces PII placeholders with original values.

Signature

Parameters

text
string
required
Text containing PII placeholder tags
piiMap
Map<string, string>
required
Decrypted PII map from decryptPIIMap()
strict
boolean
default:"false"
If true, use strict matching (exact tag format only). If false, use fuzzy matching that handles mangled tags from translation.
tagFormat
TagFormat
Tag format configuration. Must match the format used during anonymization. Defaults to XML-style (<PII type="..." id="N"/>).

Returns

Text with placeholders replaced by original values.

Example


decryptPIIMap()

Decrypts the encrypted PII map from an anonymization result.

Signature

Parameters

encryptedMap
EncryptedPIIMap
required
The encrypted PII map from result.piiMap
key
Uint8Array
required
The encryption key (same key used during anonymization)

Returns

A Map<string, string> where:
  • Key: "TYPE:id" (e.g., "EMAIL:1", "PERSON:2")
  • Value: Original PII value

Example


Complete Workflow


Session-Based Rehydration

When using sessions, rehydration is simplified:
See Sessions for details.

Placeholder Format

By default, rehydrate expects placeholders in XML-style format:
When using a custom tag format, pass the same tagFormat used during anonymization:
The function matches based on type and id attributes.

Handling Malformed Placeholders


Error Handling

Missing Key

Missing PII Entry

  • Encryption - How PII maps are encrypted
  • Sessions - Simplified rehydration with sessions
  • Crypto - Key management utilities