UNPKG

tweetnacljs

Version:

Port of TweetNaCl cryptographic library to JavaScript

18 lines (14 loc) 509 B
var nacl = (typeof window !== 'undefined') ? window.nacl : require('../' + (process.env.NACL_SRC || 'nacl.min.js')); var test = require('tape'); var randomVectors = require('./data/hash.random'); var enc = nacl.util.encodeBase64, dec = nacl.util.decodeBase64; test('nacl.hash random test vectors', function(t) { randomVectors.forEach(function(vec) { var msg = dec(vec[0]); var goodHash = dec(vec[1]); var hash = nacl.hash(msg); t.equal(enc(hash), enc(goodHash)); }); t.end(); });