Socket
Socket
Sign inDemoInstall

crypto-browserify

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-browserify - npm Package Compare versions

Comparing version 3.9.6 to 3.9.7

4

index.js

@@ -14,5 +14,5 @@ 'use strict';

exports.createHash = exports.Hash = require('./create-hash')
exports.createHash = exports.Hash = require('create-hash')
exports.createHmac = exports.Hmac = require('./create-hmac')
exports.createHmac = exports.Hmac = require('create-hmac')

@@ -19,0 +19,0 @@ exports.randomBytes = function(size, callback) {

@@ -5,3 +5,3 @@ {

"description": "implementation of crypto for the browser",
"version": "3.9.6",
"version": "3.9.7",
"homepage": "https://github.com/crypto-browserify/crypto-browserify",

@@ -21,10 +21,10 @@ "repository": {

"browserify-aes": "0.8.1",
"browserify-sign": "2.8.0",
"create-ecdh": "1.0.3",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.0",
"diffie-hellman": "2.2.3",
"browserify-sign": "2.8.0",
"inherits": "^2.0.1",
"pbkdf2-compat": "2.0.1",
"public-encrypt": "1.1.2",
"ripemd160": "0.2.0",
"sha.js": "2.3.6"
"public-encrypt": "1.1.2"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -7,33 +7,36 @@ var fs = require('fs')

var vectors = require('hash-test-vectors')
testLib('createHash in crypto-browserify',require('../').createHash);
testLib('create-hash/browser',require('create-hash/browser'));
function testLib(name, createHash) {
test(name, function (t){
algorithms.forEach(function (algorithm) {
t.test('test ' + algorithm + ' against test vectors', function (t) {
vectors.forEach(function (obj, i) {
var input = new Buffer(obj.input, 'base64')
var node = obj[algorithm]
var js = createHash(algorithm).update(input).digest('hex')
t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node)
})
var createHash = require('../create-hash')
algorithms.forEach(function (algorithm) {
test('test ' + algorithm + ' against test vectors', function (t) {
vectors.forEach(function (obj, i) {
var input = new Buffer(obj.input, 'base64')
var node = obj[algorithm]
var js = createHash(algorithm).update(input).digest('hex')
t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node)
})
encodings.forEach(function (encoding) {
encodings.forEach(function (encoding) {
vectors.forEach(function (obj, i) {
var input = new Buffer(obj.input, 'base64').toString(encoding)
var node = obj[algorithm]
var js = createHash(algorithm).update(input, encoding).digest('hex')
t.equal(js, node, algorithm + '(testVector['+i+'], '+encoding+') == ' + node)
})
});
vectors.forEach(function (obj, i) {
var input = new Buffer(obj.input, 'base64').toString(encoding)
var input = new Buffer(obj.input, 'base64')
var node = obj[algorithm]
var js = createHash(algorithm).update(input, encoding).digest('hex')
t.equal(js, node, algorithm + '(testVector['+i+'], '+encoding+') == ' + node)
var hash = createHash(algorithm);
hash.end(input)
var js = hash.read().toString('hex')
t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node)
})
t.end()
})
});
vectors.forEach(function (obj, i) {
var input = new Buffer(obj.input, 'base64')
var node = obj[algorithm]
var hash = createHash(algorithm);
hash.end(input)
var js = hash.read().toString('hex')
t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node)
})
t.end()
})
});
});
}
var test = require('tape')
var algorithms = ['sha1', 'sha256', 'sha512', 'md5', 'rmd160']
var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
var vectors = require('hash-test-vectors/hmac')
var createHmac = require('../create-hmac')
testLib('createHmac in crypto-browserify',require('../').createHmac);
testLib('create-hmac/browser',require('create-hmac/browser'));
function testLib(name, createHmac) {
test(name, function (t){
algorithms.forEach(function (alg) {
algorithms.forEach(function (alg) {
t.test('hmac('+alg+')', function (t) {
vectors.forEach(function (input, i) {
var output = createHmac(alg, new Buffer(input.key, 'hex'))
.update(input.data, 'hex').digest()
test('hmac('+alg+')', function (t) {
vectors.forEach(function (input, i) {
var output = createHmac(alg, new Buffer(input.key, 'hex'))
.update(input.data, 'hex').digest()
output = input.truncate ? output.slice(0, input.truncate) : output
t.equal(output.toString('hex'), input[alg])
})
t.end()
})
output = input.truncate ? output.slice(0, input.truncate) : output
t.equal(output.toString('hex'), input[alg])
})
t.end()
})
t.test('hmac('+alg+')', function (t) {
vectors.forEach(function (input, i) {
var hmac = createHmac(alg, new Buffer(input.key, 'hex'))
test('hmac('+alg+')', function (t) {
vectors.forEach(function (input, i) {
var hmac = createHmac(alg, new Buffer(input.key, 'hex'))
hmac.end(input.data, 'hex')
var output = hmac.read()
hmac.end(input.data, 'hex')
var output = hmac.read()
output = input.truncate ? output.slice(0, input.truncate) : output
t.equal(output.toString('hex'), input[alg])
})
t.end()
})
output = input.truncate ? output.slice(0, input.truncate) : output
t.equal(output.toString('hex'), input[alg])
})
t.end()
})
})
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc