Enable encryption for the database using AES-256-GCM.
When encryption is enabled, the database filename automatically changes to use the .enc.json extension.
For example, mydb.json becomes mydb.enc.json. This prevents accidentally accessing encrypted
databases without proper encryption settings.
This method is idempotent - calling it multiple times won't keep changing the filename.
Parameters
cipherKey: CipherKey
The encryption key. Must be exactly 32 bytes. Can be:
A string of 32 characters
A Buffer of 32 bytes
A symmetric KeyObject with 256-bit key size (from Node.js crypto module)
constconfig = newConfig('mydb', true); constkey = randomBytes(32); // 32-byte encryption key config.setEncryption(key); // Database will now be stored in 'mydb.enc.json' with encrypted data
Enable encryption for the database using AES-256-GCM.
When encryption is enabled, the database filename automatically changes to use the
.enc.jsonextension. For example,mydb.jsonbecomesmydb.enc.json. This prevents accidentally accessing encrypted databases without proper encryption settings.This method is idempotent - calling it multiple times won't keep changing the filename.