Generation

generate functionTue, 14 Mar 2023

encrypt and decrypt zip file

Script var zip = new require('node-zip')(); var key = "10"; var fs = require('fs'); zip.file('hello.txt', key + ' hello world'); // generate a buffer and log it var data = zip.generate({base64:false,compression:'DEFLATE'}); console.log(data.length); console.log('data:',data); // FIXME: here need to save the byte array into a file //fs.writeFileSync('file.zip', data, 'binary'); // write the file var zip = require('node-zip')(data, {base64: false, checkCRC32: true}); var Decrypt = require('./decrypt'); var decrypted = Decrypt(zip.file('hello.txt')._data.getContent(), key); console.log(decrypted);

Want to kickstart your project?Use the new AI Studio to create your code