Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"email": "sy@another-d-mention.ro",
"url": "https://github.com/cthackers/adm-zip/issues"
},
"dependencies": {
"fidonet-mailer-binkp-crypt": ">0.0.20"
},
"licenses": [
{
"type": "MIT",
Expand Down
23 changes: 18 additions & 5 deletions zipEntry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Utils = require("./util"),
Crypt=require("fidonet-mailer-binkp-crypt")
Headers = require("./headers"),
Constants = Utils.Constants,
Methods = require("./methods");
Expand Down Expand Up @@ -34,7 +35,11 @@ module.exports = function (/*Buffer*/input) {
return true;
}

function decompress(/*Boolean*/async, /*Function*/callback) {
function decompress(/*Boolean*/async, /*Function*/callback, /*String*/pass) {
if(typeof callback === 'undefined' && typeof async === 'string') {
pass=async;
async=void 0;
}
if (_isDirectory) {
if (async && callback) {
callback(new Buffer(0), Utils.Errors.DIRECTORY_CONTENT_ERROR); //si added error.
Expand All @@ -43,6 +48,14 @@ module.exports = function (/*Buffer*/input) {
}

var compressedData = getCompressedDataFromZip();
if (pass) {
if (_entryHeader.encripted) {
var crypt=Crypt(pass);
crypt.init_keys();
crypt.decrypt_buf(compressedData)
compressedData=compressedData.slice(12);
}
}
if (compressedData.length == 0) {
if (async && callback) callback(compressedData, Utils.Errors.NO_DATA);//si added error.
return compressedData;
Expand Down Expand Up @@ -232,12 +245,12 @@ module.exports = function (/*Buffer*/input) {
}
},

getData : function() {
return decompress(false, null);
getData : function(pass) {
return decompress(false, null, pass);
},

getDataAsync : function(/*Function*/callback) {
decompress(true, callback)
getDataAsync : function(/*Function*/callback, pass) {
decompress(true, callback, pass)
},

set header(/*Buffer*/data) {
Expand Down