Permalink
Browse files

added decode test script

  • Loading branch information...
1 parent a770873 commit 661be304b93120a62fe32ccdf2f276c9c8806cc9 @pkrumins committed Jul 10, 2010
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/node-base64-decode.js
@@ -0,0 +1,16 @@
+var base64_decode = require('base64').decode;
+var sys = require('sys');
+var fs = require('fs');
+var Buffer = require('buffer').Buffer;
+
+if (!process.argv[2]) {
+ sys.log('No argument specified, use `node-base64-decode.js <file>`');
+ process.exit(1);
+}
+
+var file = fs.readFileSync(process.argv[2], 'ascii');
+var fileBuf = new Buffer(file.length);
+fileBuf.write(file, 'ascii');
+
+process.stdout.write(base64_decode(fileBuf), 'binary');
+

0 comments on commit 661be30

Please sign in to comment.