Giter VIP home page Giter VIP logo

node-archiver-zip-encryptable's Introduction

archiver-zip-encryptable

An extension for archiver to zip with password encryption.

GitHub Actions master AppVeyor master Coveralls master npm GitHub license

This extension adds some formats to handle encryption to archiver.
Currently this package supports only creating zip with traditional PKWARE encryption.

Install

npm install archiver-zip-encryptable --save

Usage

Call archiver.registerFormat() to register this module to archiver, then archive with password.

var fs = require('fs');
var archiver = require('archiver');

archiver.registerFormat('zip-encryptable', require('archiver-zip-encryptable'));

var output = fs.createWriteStream(__dirname + '/example.zip');

var archive = archiver('zip-encryptable', {
    zlib: { level: 9 },
    forceLocalTime: true,
    password: 'test'
});
archive.pipe(output);

archive.append(Buffer.from('Hello World'), { name: 'test.txt' });
archive.append(Buffer.from('Good Bye'), { name: 'test2.txt' });

archive.finalize();

Credits

License

MIT

node-archiver-zip-encryptable's People

Contributors

dependabot[bot] avatar ksoichiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

teorge

node-archiver-zip-encryptable's Issues

Zip with password is not working

I tried to use the example to zip files with the password test but can unzip without any password input. Please help to check. Thanks.

Unable to unzip file using buffer with level 0

Hi,

Just wanted to raise an issue we encountered when we were trying to produce an archive with level 0 and a password and appending buffers instead of streams.

This can be reproduced using your test case, we just ran it to produce the zip file and tried to extract it which unfortunately did not work.

  it.only('archives files without compression', function(done) {
    // var tempDir = temp.mkdirSync('out');
    // var output = fs.createWriteStream(tempDir + '/example.zip');
    var output = fs.createWriteStream('./example.zip');
    output.on('close', function() {
      // var content = fs.readFileSync(tempDir + '/example.zip');
      // expect(content.slice(0, 4)).to.eql(Buffer.from([0x50, 0x4b, 0x03, 0x04]));
      done();
    });

    var archive = archiver('zip-encryptable', {
      zlib: { level: 0 },
      forceLocalTime: true,
      comment: 'test comment',
      password: 'test'
    });
    archive.pipe(output);
    archive.append(Buffer.from('Hello World'), { name: 'test.txt' });
    archive.finalize();
  });

Buffer

#HelpNeeded How can I get buffer of zip instead of store file in local drive.

Thanks in advance

require crc32-stream 3.x error.

var CRC32Stream = require('crc32-stream');
var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;

Should be

var CRC32Stream = require('crc32-stream');
var DeflateCRC32Stream = CRC32Stream.DeflateCRC32Stream;
if(CRC32Stream.CRC32Stream)
  CRC32Stream = CRC32Stream.CRC32Stream;

This is my pr: #17

Crashes with RangeError during streaming to S3

I used archiver to realise a full streaming solution from a storage to a storage (S3).

S3 -> compress -> S3

After I added 'archiver-zip-encryptable' I run into a issue. I tested with small files (e.g 1 mb) everything was fin. With files larger than 20 mb the underlying zip-crypto-stream.js crashes with a RangeError.

The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received 4294967479
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received 4294967479
   at checkInt (internal/buffer.js:36:11)
   at writeU_Int32BE (internal/buffer.js:628:3)
   at Buffer.writeUInt32BE (internal/buffer.js:641:10)
   at module.exports.ZipCrypto._updateKeys (/node_modules/archiver-zip-encryptable/lib/zip-crypto.js:106:16)
   at module.exports.ZipCrypto.encrypt (/node_modules/archiver-zip-encryptable/lib/zip-crypto.js:126:10)
   at module.exports.handleStuff (/node_modules/archiver-zip-encryptable/lib/zip-crypto-stream.js:79:24)
   at Object.onceWrapper (events.js:276:13)
   at module.exports.emit (events.js:193:15)
   at module.exports.EventEmitter.emit (domain.js:441:20)
   at endReadableNT (_stream_readable.js:1129:12)
   at process.internalTickCallback (internal/process/next_tick.js:72:19)

Is there any solution to fix that bug ?

<Buffer > / empty file causes error when unzipping

Hey,

Thanks for the awesome library. I have noticed that if I pass in an empty file (eg. blank.txt) and I observe the Buffer for this file (ie. ), when I try to unzip the file produced by the archiver, it does not allow me to unzip.

I tried ensuring that it was not node-archiver which is the issue (ie. not registering archiver-zip-encryptable as the format) and I can unzip and see that the blank.txt is indeed empty.

Can you shed any light on this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.