Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-hmac

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-hmac - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

30

browser.js

@@ -8,8 +8,9 @@ 'use strict';

module.exports = Hmac
module.exports = function createHmac(alg, key) {
return new Hmac(alg, key)
}
inherits(Hmac, Transform)
function Hmac (alg, key) {
if(!(this instanceof Hmac)) return new Hmac(alg, key)
Transform.call(this)
Transform.call(this);
this._opad = opad

@@ -20,3 +21,3 @@ this._alg = alg

key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
key = this._key = (typeof key === 'string') ? new Buffer(key) : key

@@ -41,7 +42,13 @@ if(key.length > blocksize) {

Hmac.prototype.update = function (data, enc) {
this.write(data, enc)
if (typeof data === 'string') {
data = new Buffer(data, enc)
}
this._hash.update(data)
return this
}
Hmac.prototype._transform = function (data, _, next) {
Hmac.prototype._transform = function (data, enc, next) {
if (enc) {
data = new Buffer(data, enc)
}
this._hash.update(data)

@@ -52,4 +59,3 @@ next()

Hmac.prototype._flush = function (next) {
var h = this._hash.digest()
this.push(createHash(this._alg).update(this._opad).update(h).digest())
this.push(this.digest())
next()

@@ -59,8 +65,4 @@ }

Hmac.prototype.digest = function (enc) {
this.end()
var outData = new Buffer('')
var chunk
while ((chunk = this.read())) {
outData = Buffer.concat([outData, chunk])
}
var h = this._hash.digest()
var outData = createHash(this._alg).update(this._opad).update(h).digest();
if (enc) {

@@ -67,0 +69,0 @@ outData = outData.toString(enc)

{
"name": "create-hmac",
"version": "1.1.0",
"version": "1.1.1",
"description": "node style hmacs in the browser",

@@ -5,0 +5,0 @@ "main": "index.js",

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