| 7 | const DEFAULT_KEY_LENGTH = 16; |
| 8 | |
| 9 | const zipStreamFile = ({ inputFile, outputFile }) => { |
| 10 | return new Promise((resolve, reject) => { |
| 11 | const highWaterMark = STREAM_SIZE; |
| 12 | const reader = fs.createReadStream(inputFile, { highWaterMark }); |
| 13 | const writer = fs.createWriteStream(outputFile); |
| 14 | reader |
| 15 | .pipe(zlib.createGzip()) |
| 16 | .pipe(writer) |
| 17 | .on('error', reject) |
| 18 | .on('finish', resolve); |
| 19 | }); |
| 20 | }; |
| 21 | |
| 22 | const encryptStreamFile = ({ inputFile, outputFile, key, iv, salt }) => { |
| 23 | return new Promise((resolve, reject) => { |