Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

decode test, fails

  • Loading branch information...
commit 83f7b2aaa85cc2ac9250ec550f051c1842262135 1 parent a4ef9b3
@substack substack authored
Showing with 15 additions and 11 deletions.
  1. +15 −11 test/decode.js
View
26 test/decode.js
@@ -1,16 +1,20 @@
var base64_decode = require('base64').decode;
-var sys = require('sys');
+var crypto = require('crypto');
var fs = require('fs');
-var Buffer = require('buffer').Buffer;
+var Hash = require('traverse/hash');
+var hashes = JSON.parse(
+ fs.readFileSync(__dirname + '/hashes.json').toString()
+);
-if (!process.argv[2]) {
- sys.log('No argument specified, use `node-base64-decode.js <file>`');
- process.exit(1);
+function md5sum (data) {
+ return new crypto.Hash('md5').update(data).digest('hex');
}
-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');
-
+exports.decode = function (assert) {
+ Hash(hashes).forEach(function (hash, file) {
+ fs.readFile(file, function (err, buf) {
+ if (err) throw err;
+ assert.equal(hash, md5sum(base64_decode(buf)));
+ });
+ });
+};

0 comments on commit 83f7b2a

Please sign in to comment.
Something went wrong with that request. Please try again.