New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-hash

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-hash - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

63

browser.js

@@ -7,6 +7,6 @@ 'use strict';

var Transform = require('stream').Transform
var Base = require('cipher-base')
function HashNoConstructor(hash) {
Transform.call(this)
Base.call(this, 'digest')

@@ -17,25 +17,9 @@ this._hash = hash

inherits(HashNoConstructor, Transform)
inherits(HashNoConstructor, Base)
HashNoConstructor.prototype._transform = function (data, _, next) {
HashNoConstructor.prototype._update = function (data) {
this.buffers.push(data)
next()
}
HashNoConstructor.prototype._flush = function (next) {
this.push(this.digest())
next()
}
HashNoConstructor.prototype.update = function (data, enc) {
if (typeof data === 'string') {
data = new Buffer(data, enc)
}
this.buffers.push(data)
return this
}
HashNoConstructor.prototype.digest = function (enc) {
HashNoConstructor.prototype._final = function () {
var buf = Buffer.concat(this.buffers)

@@ -45,7 +29,7 @@ var r = this._hash(buf)

return enc ? r.toString(enc) : r
return r
}
function Hash(hash) {
Transform.call(this)
Base.call(this, 'digest')

@@ -55,39 +39,18 @@ this._hash = hash

inherits(Hash, Transform)
inherits(Hash, Base)
Hash.prototype._transform = function (data, enc, next) {
if (enc) data = new Buffer(data, enc)
Hash.prototype._update = function (data) {
this._hash.update(data)
next()
}
Hash.prototype._flush = function (next) {
this.push(this._hash.digest())
this._hash = null
next()
Hash.prototype._final = function () {
return this._hash.digest()
}
Hash.prototype.update = function (data, enc) {
if (typeof data === 'string') {
data = new Buffer(data, enc)
}
this._hash.update(data)
return this
}
Hash.prototype.digest = function (enc) {
var outData = this._hash.digest()
return enc ? outData.toString(enc) : outData
}
module.exports = function createHash (alg) {
alg = alg.toLowerCase()
if ('md5' === alg) return new HashNoConstructor(md5)
if ('rmd160' === alg) return new HashNoConstructor(rmd160)
if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160)
return new Hash(sha(alg))
}
{
"name": "create-hash",
"version": "1.1.1",
"version": "1.1.2",
"description": "create hashes for browserify",

@@ -29,2 +29,3 @@ "browser": "browser.js",

"dependencies": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",

@@ -31,0 +32,0 @@ "ripemd160": "^1.0.0",

var fs = require('fs')
var test = require('tape')
var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160', 'ripemd160']
var encodings = [/*'binary',*/ 'hex', 'base64'];
var vectors = require('hash-test-vectors')
vectors.forEach(function (vector) {
vector.ripemd160 = vector.rmd160
})
var createHash = require('./browser')

@@ -9,0 +11,0 @@

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