Socket
Socket
Sign inDemoInstall

browserify-sha3

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify-sha3 - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

22

index.js
const Sha3 = require('js-sha3')
const Buffer = require('safe-buffer').Buffer
const hashLengths = [ 224, 256, 384, 512 ]
var hash = function (bitcount) {
if (bitcount !== undefined && hashLengths.indexOf(bitcount) == -1)
const hash = function (bitcount) {
if (bitcount !== undefined && hashLengths.indexOf(bitcount) === -1) {
throw new Error('Unsupported hash length')
}
this.content = []

@@ -13,8 +15,9 @@ this.bitcount = bitcount ? 'keccak_' + bitcount : 'keccak_512'

hash.prototype.update = function (i) {
if (Buffer.isBuffer(i))
if (Buffer.isBuffer(i)) {
this.content.push(i)
else if (typeof i === 'string')
} else if (typeof i === 'string') {
this.content.push(new Buffer(i))
else
} else {
throw new Error('Unsupported argument to update')
}
return this

@@ -24,9 +27,10 @@ }

hash.prototype.digest = function (encoding) {
var result = Sha3[this.bitcount](Buffer.concat(this.content))
if (encoding === 'hex')
const result = Sha3[this.bitcount](Buffer.concat(this.content))
if (encoding === 'hex') {
return result
else if (encoding === 'binary' || encoding === undefined)
} else if (encoding === 'binary' || encoding === undefined) {
return new Buffer(result, 'hex').toString('binary')
else
} else {
throw new Error('Unsupported encoding for digest: ' + encoding)
}
}

@@ -33,0 +37,0 @@

{
"name": "browserify-sha3",
"version": "0.0.3",
"version": "0.0.4",
"description": "node-sha3 compatability for browserify",

@@ -28,4 +28,5 @@ "main": "index.js",

"dependencies": {
"js-sha3": "^0.6.1"
"js-sha3": "^0.6.1",
"safe-buffer": "^5.1.1"
}
}
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