Skip to content

Commit 5657c76

Browse files
committed
vectors: adhere to standard
1 parent e6851ca commit 5657c76

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

test/vectors.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
2-
var vectors = require('hash-test-vectors')
31
var tape = require('tape')
4-
//var from = require('bops/typedarray/from')
2+
var vectors = require('hash-test-vectors')
3+
// var from = require('bops/typedarray/from')
54
var Buffer = require('buffer').Buffer
65
var hexpp = require('../hexpp')
76

87
var createHash = require('../')
98

10-
function makeTest(alg, i, verbose) {
9+
function makeTest (alg, i, verbose) {
1110
var v = vectors[i]
1211

1312
tape(alg + ': NIST vector ' + i, function (t) {
14-
if(verbose) {
13+
if (verbose) {
1514
console.log(v)
1615
console.log('VECTOR', i)
1716
console.log('INPUT', v.input)
1817
console.log(hexpp(new Buffer(v.input, 'base64')))
1918
console.log(new Buffer(v.input, 'base64').toString('hex'))
2019
}
20+
2121
var buf = new Buffer(v.input, 'base64')
2222
t.equal(createHash(alg).update(buf).digest('hex'), v[alg])
2323

@@ -38,8 +38,8 @@ function makeTest(alg, i, verbose) {
3838

3939
var j, buf3
4040

41-
i = ~~(buf.length / 3)
42-
j = ~~(buf.length * 2 / 3)
41+
i = ~~(buf.length / 3)
42+
j = ~~(buf.length * 2 / 3)
4343
buf1 = buf.slice(0, i)
4444
buf2 = buf.slice(i, j)
4545
buf3 = buf.slice(j, buf.length)
@@ -54,16 +54,17 @@ function makeTest(alg, i, verbose) {
5454
)
5555

5656
setTimeout(function () {
57-
//avoid "too much recursion" errors in tape in firefox
57+
// avoid "too much recursion" errors in tape in firefox
5858
t.end()
5959
})
6060
})
6161

6262
}
6363

64-
if(process.argv[2])
65-
makeTest(process.argv[2], parseInt(process.argv[3]), true)
66-
else
64+
if (process.argv[2]) {
65+
makeTest(process.argv[2], parseInt(process.argv[3], 10), true)
66+
67+
} else {
6768
vectors.forEach(function (v, i) {
6869
makeTest('sha', i)
6970
makeTest('sha1', i)
@@ -72,6 +73,4 @@ else
7273
makeTest('sha384', i)
7374
makeTest('sha512', i)
7475
})
75-
76-
77-
76+
}

0 commit comments

Comments
 (0)