Socket
Socket
Sign inDemoInstall

crypto-browserify

Package Overview
Dependencies
Maintainers
1
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 0.2.3 to 0.3.0

45

index.js

@@ -19,2 +19,16 @@ var Buffer = require('buffer').Buffer

var algorithmsHmac = {
sha1: {
hex: sha.hex_hmac_sha1,
binary: sha.b64_hmac_sha1,
ascii: sha.str_hmac_sha1
},
md5: {
hex: md5.hex_hmac_md5,
binary: md5.b64_hmac_md5,
ascii: md5.any_hmac_md5
}
}
function error () {

@@ -52,2 +66,26 @@ var m = [].slice.call(arguments).join(' ')

exports.createHmac = function (alg, key) {
if (!algorithmsHmac[alg])
error('algorithm:', alg, 'is not yet supported')
if (typeof key != 'string')
key = key.toString('binary')
var s = ''
var _alg = algorithmsHmac[alg]
return {
update: function (data) {
s += data
return this
},
digest: function (enc) {
enc = enc || 'binary'
var fn
if (!(fn = _alg[enc]))
error('encoding:', enc, 'is not yet support for algorithm', alg)
var r = fn(key, s)
s = null
return r
}
}
}
exports.randomBytes = function(size, callback) {

@@ -70,5 +108,4 @@ if (callback && callback.call) {

each(['createCredentials'
, 'createHmac'
, 'createCypher'
, 'createCypheriv'
, 'createCipher'
, 'createCipheriv'
, 'createDecipher'

@@ -78,3 +115,3 @@ , 'createDecipheriv'

, 'createVerify'
, 'createDeffieHellman'
, 'createDiffieHellman'
, 'pbkdf2'], function (name) {

@@ -81,0 +118,0 @@ exports[name] = function () {

@@ -385,1 +385,4 @@ /*

exports.any_md5 = any_md5;
exports.hex_hmac_md5 = hex_hmac_md5;
exports.b64_hmac_md5 = b64_hmac_md5;
exports.any_hmac_md5 = any_hmac_md5;

2

package.json

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

"description": "partial implementation of crypto for the browser",
"version": "0.2.3",
"version": "0.3.0",
"homepage": "https://github.com/dominictarr/crypto-browserify",

@@ -8,0 +8,0 @@ "repository": {

@@ -22,6 +22,14 @@ var test = require("tape")

assertSame(function md5(crypto, cb) {
assertSame(function md5 (crypto, cb) {
cb(null, crypto.createHash('md5').update('hello', 'utf-8').digest('hex'))
})
assertSame(function sha1hmac (crypto, cb) {
cb(null, crypto.createHmac('sha1', 'secret').update('hello', 'utf-8').digest('hex'))
})
assertSame(function md5hmac (crypto, cb) {
cb(null, crypto.createHmac('md5', 'secret').update('hello', 'utf-8').digest('hex'))
})
test('randomBytes', function (t) {

@@ -28,0 +36,0 @@ t.plan(5)

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