Create a new transformer with the given encryption configuration.
Encrypt a value before it is written to the database.
null / undefined values pass through unchanged."v2:" followed by the Base64 sealed box
(nonce + ciphertext + tag).Decrypt a value after it is read from the database.
null / undefined values pass through unchanged.
A TypeORM
ValueTransformerthat transparently encrypts column values before they are persisted and decrypts them when they are loaded.Uses crypto-lib's secretbox (XChaCha20-Poly1305) under the hood: each write generates a fresh random nonce, and the output is stored as
"v2:" + Base64(nonce || ciphertext || tag), bound toconfig.contextas associated data.Example