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.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 sealed output is stored as a Base64 string in the database.
Example