Node.js 如何在Nodejs中对zip文件进行密码保护?
我正在使用archiver创建一个zip文件。下面是我的代码。我需要密码保护它。我怎么做Node.js 如何在Nodejs中对zip文件进行密码保护?,node.js,node-archiver,Node.js,Node Archiver,我正在使用archiver创建一个zip文件。下面是我的代码。我需要密码保护它。我怎么做 var head={'Content-Type':'application/octet-stream','Content-disposition':'attachment; filename='+zipName,'Transfer-Encoding':'chunked' } res.writeHead(200,head); var archive = archiver('zip'); archive.
var head={'Content-Type':'application/octet-stream','Content-disposition':'attachment; filename='+zipName,'Transfer-Encoding':'chunked' }
res.writeHead(200,head);
var archive = archiver('zip');
archive.pipe(res);
archive.append(result, { name: attachment.aliasFileName });
archive.finalize();
return res.send("thanks");
如果你在linux上工作,你可以做这样的事情
//create a zip
spawn = require('child_process').spawn;
zip = spawn('zip',['-P', 'password' , 'archive.zip', 'complete path to archive file']);
zip .on('exit', function(code) {
...// Do something with zipfile archive.zip
...// which will be in same location as file/folder given
});
请参阅Archiver不支持密码@prinzhorn:我可以使用crypto-then对zip文件进行密码保护吗?如果希望与zip兼容,则不支持。该文件只能由您的系统读取,而不能由第三方zip客户端读取。至少要相信原始人。