Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Slightly minified output

  • Loading branch information...
commit 33f58e656302ed290203f1657fc098021e948de2 1 parent e552085
@chriso authored
Showing with 13 additions and 21 deletions.
  1. +8 −12 README.md
  2. +1 −1  package.json
  3. +4 −8 packnode
View
20 README.md 100755 → 100644
@@ -10,7 +10,7 @@ To pack a module using a password (e.g. `pass123`), run
$ cat myscript.js | packnode pass123 > packed.js
-Encrypted modules can be accessed by calling `unpack(password)`
+Encrypted modules can be accessed by calling `require(module).unpack(password)`
require('./packed').unpack('pass123'); //Same as require('./myscript')
@@ -28,17 +28,13 @@ hello1.js
hello2.js
- 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") + decipher.final("utf8");
- eval(unpacked); return exports;
- }(exports, packed));
- return exports;
- };
+ packed = "fec9063967f14579d132aafe31e1747dea6aeea1d396db60f9eb48d1d424e5bfcb32a74454346166";
+ packed += "55132c4d04a6b37b59e1a3d4857ad56fa3f242200b8b27272a5d4f6460fcce96b5a9290df4df9bcf";
+ exports.unpack = function (password) {
+ var decipher = require("crypto").createDecipher("aes256", password);
+ eval(decipher.update(packed, "hex", "utf8") + decipher.final("utf8"));
+ return exports;
+ };
Running both modules
View
2  package.json 100755 → 100644
@@ -1,6 +1,6 @@
{ "name" : "pack",
"description" : "Create private node modules",
- "version" : "0.1.1",
+ "version" : "0.1.2",
"homepage" : "http://github.com/chriso/packnode",
"keywords" : ["pack","packnode","encrypt","compress","unpack"],
"author" : "Chris O'Hara <cohara87@gmail.com>",
View
12 packnode
@@ -67,16 +67,12 @@ stdin.on('end', function () {
}
// Prepare the output
- packed = 'var crypto = require("crypto");\n'
- packed += 'packed = "' + chunk.join('";\npacked += "') + '";\n';
+ packed = 'packed = "' + chunk.join('";\npacked += "') + '";\n';
packed += 'exports.unpack = function (password) {\n';
- packed += ' var decipher = crypto.createDecipher("' + algorithm + '", password);\n';
- packed += ' exports = (function (exports, packed) {\n';
- packed += ' var unpacked = decipher.update(packed, "' + encoding + '", "utf8") + decipher.final("utf8");\n';
- packed += ' eval(unpacked); return exports;\n';
- packed += ' }(exports, packed));\n';
+ packed += ' var decipher = require("crypto").createDecipher("' + algorithm + '", password);\n';
+ packed += ' eval(decipher.update(packed, "' + encoding + '", "utf8") + decipher.final("utf8"));\n';
packed += ' return exports;\n';
- packed += '};\n';
+ packed += '};';
// ..and write to stdout
process.stdout.write(packed);
Please sign in to comment.
Something went wrong with that request. Please try again.