Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated readme & fixed small bug

  • Loading branch information...
commit 4928412a7ad9b700d6819eaba646434f19ba635e 1 parent dd5493b
@chriso authored
Showing with 34 additions and 3 deletions.
  1. +32 −1 README.md
  2. +1 −1  package.json
  3. +1 −1  packnode
View
33 README.md
@@ -24,4 +24,35 @@ To specify a custom encryption algorithm or output encoding, use `-a` and `-e`
Encrypted modules can be accessed by calling `unpack(password)`
- require('./packed').unpack('pass123'); //Same as require('./myscript')
+ require('./packed').unpack('pass123'); //Same as require('./myscript')
+
+## Example
+
+The following example was packed using
+
+ $ packnode pass123 < hello1.js > hello2.js
+
+`hello1.js`
+
+ exports.world = function () {
+ console.log('Hello world!');
+ };
+
+`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;
+ };
+
+Running both modules
+
+ require('./hello1').world(); //Outputs 'Hello world!'
+ require('./hello2').unpack('pass123').world(); //Outputs 'Hello world!'
View
2  package.json
@@ -1,6 +1,6 @@
{ "name" : "pack",
"description" : "Create private node modules",
- "version" : "0.1.0",
+ "version" : "0.1.1",
"homepage" : "http://github.com/chriso/packnode",
"keywords" : ["pack","packnode","encrypt","compress","unpack"],
"author" : "Chris O'Hara <cohara87@gmail.com>",
View
2  packnode
@@ -6,7 +6,7 @@ var fs = require('fs'),
var stdin = process.openStdin(), input = '';
-var cipher, data, encrypted, packed, chunk = [],
+var cipher, data = '', encrypted, packed, chunk = [],
encoding = 'hex',
algorithm = 'aes256',
chunk_length = 80,
Please sign in to comment.
Something went wrong with that request. Please try again.