Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump db content to a encrypted data file #79

Open
mikilion opened this issue Oct 10, 2018 · 2 comments
Open

Dump db content to a encrypted data file #79

mikilion opened this issue Oct 10, 2018 · 2 comments

Comments

@mikilion
Copy link

Is it possible to encrypt data when writing the dump to the file?

@reconbot
Copy link

Sure, but that would have to be handled by another stream. I can't personally recommend any specific approach, but I did find the following article interesting on the topic. https://medium.com/@brandonstilson/lets-encrypt-files-with-node-85037bea8c0e

@arunp0
Copy link

arunp0 commented May 25, 2019

I am not sure this is a right implementation but as a node implementation example u can you use this.

`
const initVect = crypto.randomBytes(16);

const backup = async () => {

const algorithm = 'aes256';
const password = 'd6F3Efeq';

// zip content
const zip = zlib.createGzip();
// encrypt content
const encrypt = crypto.createCipheriv(algorithm, password, initVect);
// write file
const w = fs.createWriteStream('backup.txt');
zip.pipe(encrypt).pipe(w);
await db.dump(zip, options);

};
`

`
const restore = async () => {

const algorithm = 'aes256;
const password = 'd6F3Efeq';

// zip content
const unzip = zlib.createGunzip();
// encrypt content
const decrypt = crypto.createDecipheriv(algorithm, password, initVect);
// write file
const r = fs.createReadStream('backup.txt');

r.pipe(decrypt).pipe(unzip);

await db.load(unzip);

};
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants