Skip to content

Commit e9e23f2

Browse files
committed
bring back binary encoding tests since [email protected]
1 parent c50c320 commit e9e23f2

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

test/create-hash.js

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,16 @@ algorithms.forEach(function (algorithm) {
1717
})
1818
});
1919

20-
// assertSame(algorithm + ' with raw binary', function (crypto, cb) {
21-
// var seed = 'hellø';
22-
// for (var i = 0; i < 1000; i++) {
23-
// seed = crypto.createHash(algorithm).update(new Buffer(seed)).digest('binary');
24-
// }
25-
// cb(null, crypto.createHash(algorithm).update(new Buffer(seed)).digest('hex'));
26-
// });
20+
assertSame(algorithm + ' with raw binary', function (crypto, cb) {
21+
var seed = 'hellø';
22+
for (var i = 0; i < 1000; i++) {
23+
seed = crypto.createHash(algorithm).update(new Buffer(seed)).digest('binary');
24+
}
25+
cb(null, crypto.createHash(algorithm).update(new Buffer(seed)).digest('hex'));
26+
});
2727

2828
assertSame(algorithm + ' empty string', function (crypto, cb) {
2929
cb(null, crypto.createHash(algorithm).update('').digest('hex'));
3030
});
3131
});
3232

33-
//function pad(n, w) {
34-
// n = n + ''; return new Array(w - n.length + 1).join('0') + n;
35-
//}
36-
//
37-
//var vectors = fs.readdirSync(__dirname + '/vectors').sort().
38-
// filter(function (t) { return t.match(/\.dat$/); }).
39-
// map(function (t) { return fs.readFileSync(__dirname + '/vectors/' + t); });
40-
//
41-
//['md5', 'sha1', 'sha256'].forEach(function (algorithm) {
42-
// test(algorithm, function (t) {
43-
// function hash(data) { return cryptoB.createHash(algorithm).update(data).digest('hex'); }
44-
//
45-
// var hashes = fs.readFileSync(__dirname + '/vectors/byte-hashes.' + algorithm).toString().split(/\r?\n/);
46-
// t.plan(vectors.length);
47-
// for (var i = 0; i < vectors.length; i++) {
48-
// t.equal(hash(vectors[i]), hashes[i], 'byte' + pad(i, 4) + '.dat');
49-
// }
50-
// });
51-
//});
52-
//

test/node.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ algorithms.forEach(function (algorithm) {
2121
})
2222
});
2323

24-
// assertSame(algorithm + ' with raw binary', function (crypto, cb) {
25-
// var seed = 'hellø';
26-
// for (var i = 0; i < 1000; i++) {
27-
// seed = crypto.createHash(algorithm).update(new Buffer(seed)).digest('binary');
28-
// }
29-
// cb(null, crypto.createHash(algorithm).update(new Buffer(seed)).digest('hex'));
30-
// });
24+
assertSame(algorithm + ' with raw binary', function (crypto, cb) {
25+
var seed = 'hellø';
26+
for (var i = 0; i < 1000; i++) {
27+
seed = crypto.createHash(algorithm).update(new Buffer(seed)).digest('binary');
28+
}
29+
cb(null, crypto.createHash(algorithm).update(new Buffer(seed)).digest('hex'));
30+
});
3131

3232
assertSame(algorithm + ' empty string', function (crypto, cb) {
3333
cb(null, crypto.createHash(algorithm).update('').digest('hex'));

0 commit comments

Comments
 (0)