bitcoinjs-lib/test/crypto.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-04-08 15:39:22 +02:00
var assert = require('assert')
var crypto = require('../').crypto
var fixture = require('./fixtures/crypto')
describe('Crypto', function() {
describe('HASH160', function() {
it('matches the test vector', function() {
fixture.before.hex.forEach(function(hex, i) {
var actual = crypto.hash160(new Buffer(hex, 'hex')).toString('hex')
var expected = fixture.after.hash160[i]
2014-04-08 15:50:27 +02:00
assert.equal(actual, expected)
2014-04-08 15:39:22 +02:00
})
})
})
describe('HASH256', function() {
it('matches the test vector', function() {
fixture.before.hex.forEach(function(hex, i) {
var actual = crypto.hash256(new Buffer(hex, 'hex')).toString('hex')
var expected = fixture.after.hash256[i]
2014-04-08 15:50:27 +02:00
assert.equal(actual, expected)
2014-04-08 15:39:22 +02:00
})
})
})
describe('SHA1', function() {
it('matches the test vector', function() {
fixture.before.hex.forEach(function(hex, i) {
var actual = crypto.sha1(new Buffer(hex, 'hex')).toString('hex')
var expected = fixture.after.sha1[i]
2014-04-08 15:50:27 +02:00
assert.equal(actual, expected)
2014-04-08 15:39:22 +02:00
})
})
})
describe('SHA256', function() {
it('matches the test vector', function() {
fixture.before.hex.forEach(function(hex, i) {
var actual = crypto.sha256(new Buffer(hex, 'hex')).toString('hex')
var expected = fixture.after.sha256[i]
2014-04-08 15:50:27 +02:00
assert.equal(actual, expected)
2014-04-08 15:39:22 +02:00
})
})
})
})