Sha256: 0277a1331cdb4d64ff71007dc38753875b3f0182ffc2b2aba5a83ab4ff0eebe7
Contents?: true
Size: 1.17 KB
Versions: 65
Compression:
Stored size: 1.17 KB
Contents
var assert = require('assert') var crypto = require('crypto') var fs = require('fs') var path = require('path') var dir = path.join(__dirname, 'vectors') var vectors = fs.readdirSync(dir) .sort() .filter(function (f) { return f.match(/\.dat$/) }) .map(function (f) { return fs.readFileSync(path.join(dir, f)) }) var hashes = {} ;['sha1', 'sha256', 'md5'].forEach(function (name) { hashes[name] = fs.readFileSync(path.join(dir, 'byte-hashes.' + name), 'ascii') .split(/\r?\n/) }) var expected = [] for (var i = 0; i < vectors.length; i++) { var sha512 = crypto.createHash('sha512').update(new Buffer(vectors[i])).digest('hex') expected.push({ input : vectors[i].toString('base64'), sha1 : hashes.sha1[i], sha256 : hashes.sha256[i], sha512 : sha512 }) assert.equal( crypto.createHash('sha1').update(new Buffer(vectors[i])).digest('hex'), hashes.sha1[i]) assert.equal( crypto.createHash('sha256').update(new Buffer(vectors[i])).digest('hex'), hashes.sha256[i]) assert.equal( crypto.createHash('md5').update(new Buffer(vectors[i])).digest('hex'), hashes.md5[i]) } console.log(JSON.stringify(expected, null, 2))
Version data entries
65 entries across 65 versions & 2 rubygems