StaticdecryptStaticencryptStaticgenerateGenerates a base64-encoded random key suitable for the given algorithm.
const newKey = Encrypt.generateKey('aes-256-gcm').current and legacy. For
encrypted columns: dreamApp.set('encryption', { columns: { current: { algorithm: 'aes-256-gcm', key: newKey }, legacy: { algorithm: 'aes-256-gcm', key: oldKey } } }). For cookies, use the equivalent
shape under psychicApp.set('encryption', { cookies: { current, legacy } }).current; existing ciphertext continues
to decrypt via legacy fallback.maxAge so all in-flight
cookies have either expired or been re-issued under the new key. For
@Encrypted columns, re-encrypt every existing row under the new
key (read each row and write it back; the setter re-encrypts with
current).legacy from config and deploy again.legacymaxAge, so in-flight sessions are
not forced to re-authenticate.@Encrypted columns: until every existing row has been
re-encrypted under the new key. Dropping legacy early will cause
DecryptionRotationError on any not-yet-rewritten row.Staticvalidate
Decrypts a value previously produced by Encrypt.encrypt.
Behavior depends on whether
legacyOptsis provided:Two-arg form (no rotation):
null/undefinedinput returnsnull.DecryptionError.DecryptionParseError.Three-arg form (rotation): tries the current key first; on
DecryptionErrorfalls back to the legacy key. If both fail, throwsDecryptionRotationErrorcarrying both per-key errors. ADecryptionParseErrorfrom the current key is not retried — the cipher already matched, so a parse failure means the encrypted format is wrong (an app bug), not a wrong key.MissingEncryptionKeypropagates from either form when a key is missing.