Created
December 22, 2013 08:18
-
-
Save jduncanator/8079713 to your computer and use it in GitHub Desktop.
Simple node.js script to generate test vectors for crypto-browserify. For HMAC, the current test vectors take `boo` as the key (as seen below), for Hashes, just change `createHmac` to `createHash` and loose the 2nd parameter and run it again!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto') | |
, fs = require('fs'); | |
var algos = [ 'md4', 'md5', 'sha1', 'sha224', 'sha256' ]; | |
var vectors = {}; | |
algos.forEach(function(algo) { | |
vectors[algo] = { | |
'Test123': { | |
'hex': crypto.createHmac(algo, 'boo').update('Test123').digest('hex'), | |
'binary': crypto.createHmac(algo, 'boo').update('Test123').digest('binary'), | |
'base64': crypto.createHmac(algo, 'boo').update('Test123').digest('base64') | |
}, | |
'hellø' : { | |
'hex': crypto.createHmac(algo, 'boo').update('hellø', 'utf8').digest('hex') | |
} | |
} | |
}) | |
fs.writeFileSync('output.json', JSON.stringify(vectors, null, ' ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment