Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 40dbb98a13
Fetching contributors…

Cannot retrieve contributors at this time

executable file 57 lines (35 sloc) 1.669 kb

Packnode encrypts node modules for private use

To install packnode, use npm

$ npm install pack

Packing a module

To pack a module using a password (e.g. pass123), run

$ cat myscript.js | packnode pass123 > packed.js

CoffeeScript modules can be packed using

$ cat | coffee -c -s | packnode pass123 > packed.js

To specify a custom encryption algorithm or output encoding, use -a and -e

$ packnode -a aes256 -e hex < myscript.js > packed.js

Using a packed module

Encrypted modules can be accessed by calling unpack(password)

require('./packed').unpack('pass123'); //Same as require('./myscript')


The following example was packed using

$ packnode pass123 < hello1.js > hello2.js

hello1.js = function () {
    console.log('Hello world!');


var crypto = require("crypto");
packed = "fec9063967f14579d132aafe31e1747df6a33318a847e7d8720821294c3ecb0791bcbabd58231b35";
packed += "719efa39799269f5d7af18fee4b1c5e06d3291b099f90134481942ece7acd931f09c0ea34aaafcc1";
exports.unpack = function (password) {
    var decipher = crypto.createDecipher("aes256", password);
    exports = (function (exports, packed) {
        var unpacked = decipher.update(packed, "hex", "utf8") +"utf8");
        eval(unpacked); return exports;
    }(exports, packed));
    return exports;

Running both modules

require('./hello1').world();                    //Outputs 'Hello world!'
require('./hello2').unpack('pass123').world();  //Outputs 'Hello world!'
Jump to Line
Something went wrong with that request. Please try again.