Socket
Socket
Sign inDemoInstall

multihashing-async

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multihashing-async - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

dist/index.min.js.LICENSE.txt

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="0.8.1"></a>
## [0.8.1](https://github.com/multiformats/js-multihashing-async/compare/v0.8.0...v0.8.1) (2020-03-14)
### Bug Fixes
* expose sha ([#66](https://github.com/multiformats/js-multihashing-async/issues/66)) ([dbe2a4a](https://github.com/multiformats/js-multihashing-async/commit/dbe2a4a))
<a name="0.8.0"></a>

@@ -2,0 +12,0 @@ # [0.8.0](https://github.com/multiformats/js-multihashing-async/compare/v0.7.0...v0.8.0) (2019-09-12)

29

package.json
{
"name": "multihashing-async",
"version": "0.8.0",
"version": "0.8.1",
"description": "multiple hash functions",

@@ -45,3 +45,3 @@ "keywords": [

"devDependencies": {
"aegir": "^20.1.0",
"aegir": "^21.3.0",
"benchmark": "^2.1.4",

@@ -57,26 +57,21 @@ "chai": "^4.1.2",

"contributors": [
"André Cruz <andremiguelcruz@msn.com>",
"Arve Knudsen <arve.knudsen@gmail.com>",
"David Dias <daviddias.p@gmail.com>",
"David Dias <mail@daviddias.me>",
"Dmitriy Ryajov <dryajov@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Harlan T Wood <harlantwood@users.noreply.github.com>",
"Hugo Dias <hugomrdias@gmail.com>",
"Hugo Dias <mail@hugodias.me>",
"Irakli Gozalishvili <contact@gozala.io>",
"Jacob Heun <jacobheun@gmail.com>",
"Juan Batiz-Benet <juan@benet.ai>",
"Marcin Rataj <lidel@lidel.org>",
"Matteo Collina <matteo.collina@gmail.com>",
"Richard Littauer <richard.littauer@gmail.com>",
"Pedro Teixeira <i@pgte.me>",
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
"Mikeal Rogers <mikeal.rogers@gmail.com>",
"Mitar <mitar.github@tnode.com>",
"Pedro Teixeira <i@pgte.me>",
"Richard Littauer <richard.littauer@gmail.com>",
"Richard Schneider <makaretu@gmail.com>",
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
"Volker Mische <volker.mische@gmail.com>",
"dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>",
"npm-to-cdn-bot (by Forbes Lindesay) <npmcdn-to-unpkg-bot@users.noreply.github.com>"
"André Cruz <andremiguelcruz@msn.com>",
"Arve Knudsen <arve.knudsen@gmail.com>",
"Dmitriy Ryajov <dryajov@gmail.com>",
"Irakli Gozalishvili <contact@gozala.io>",
"Jacob Heun <jacobheun@gmail.com>",
"Marcin Rataj <lidel@lidel.org>",
"Matteo Collina <matteo.collina@gmail.com>"
]
}

@@ -6,3 +6,3 @@ 'use strict'

const mur = require('murmurhash3js-revisited')
const sha = require('./sha')
const { factory: sha } = require('./sha')
const { fromNumberTo32BitBuf } = require('./utils')

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

@@ -0,8 +1,10 @@

/* eslint-disable require-await */
'use strict'
const { Buffer } = require('buffer')
const multihash = require('multihashes')
const crypto = self.crypto || self.msCrypto
module.exports = (algorithm) => {
const digest = async (data, alg) => {
if (typeof self === 'undefined' || (!self.crypto && !self.msCrypto)) {

@@ -13,19 +15,27 @@ throw new Error(

}
return async (data) => {
switch (algorithm) {
case 'sha1':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-1' }, data))
case 'sha2-256':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-256' }, data))
case 'sha2-512':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-512' }, data))
case 'dbl-sha2-256': {
const d = await crypto.subtle.digest({ name: 'SHA-256' }, data)
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-256' }, d))
}
default:
throw new Error(`${algorithm} is not a supported algorithm`)
switch (alg) {
case 'sha1':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-1' }, data))
case 'sha2-256':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-256' }, data))
case 'sha2-512':
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-512' }, data))
case 'dbl-sha2-256': {
const d = await crypto.subtle.digest({ name: 'SHA-256' }, data)
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-256' }, d))
}
default:
throw new Error(`${alg} is not a supported algorithm`)
}
}
module.exports = {
factory: (alg) => async (data) => {
return digest(data, alg)
},
digest,
multihashing: async (buf, alg, length) => {
const h = await digest(buf, alg, length)
return multihash.encode(h, alg, length)
}
}

@@ -0,3 +1,5 @@

/* eslint-disable require-await */
'use strict'
const crypto = require('crypto')
const multihash = require('multihashes')

@@ -8,4 +10,4 @@ // Note that although this function doesn't do any asynchronous work, we mark

// eslint-disable-next-line
module.exports = (algorithm) => async (data) => {
switch (algorithm) {
const digest = async (data, alg) => {
switch (alg) {
case 'sha1':

@@ -22,4 +24,15 @@ return crypto.createHash('sha1').update(data).digest()

default:
throw new Error(`${algorithm} is not a supported algorithm`)
throw new Error(`${alg} is not a supported algorithm`)
}
}
module.exports = {
factory: (alg) => async (data) => {
return digest(data, alg)
},
digest,
multihashing: async (buf, alg, length) => {
const h = await digest(buf, alg, length)
return multihash.encode(h, alg, length)
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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