From 514fc8d326fbd017c0d456cfee6c2b7a2a29341d Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 19 May 2016 23:38:12 -0400 Subject: [PATCH] crypto: switch to Node.js sha512 The sha512 library has not been updated in quite some time. This switches to use Node.js crypto for sha512 that will use crypto-browserify, and more recently maintained sha.js for the browser build. --- lib/crypto/hash.js | 4 +--- npm-shrinkwrap.json | 5 ----- package.json | 3 +-- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/crypto/hash.js b/lib/crypto/hash.js index 2b098b7..01e4d15 100644 --- a/lib/crypto/hash.js +++ b/lib/crypto/hash.js @@ -1,6 +1,5 @@ 'use strict'; -var sha512 = require('sha512'); var crypto = require('crypto'); var BufferUtil = require('../util/buffer'); var $ = require('../util/preconditions'); @@ -38,8 +37,7 @@ Hash.sha256ripemd160 = function(buf) { Hash.sha512 = function(buf) { $.checkArgument(BufferUtil.isBuffer(buf)); - var hash = sha512(buf); - return new Buffer(hash); + return crypto.createHash('sha512').update(buf).digest(); }; Hash.sha512.blocksize = 1024; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e141aaa..53fc6c6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -43,11 +43,6 @@ "version": "3.10.1", "from": "lodash@=3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" - }, - "sha512": { - "version": "0.0.1", - "from": "sha512@=0.0.1", - "resolved": "https://registry.npmjs.org/sha512/-/sha512-0.0.1.tgz" } } } diff --git a/package.json b/package.json index 6e18ad8..e981aec 100644 --- a/package.json +++ b/package.json @@ -85,8 +85,7 @@ "buffer-compare": "=1.0.0", "elliptic": "=3.0.3", "inherits": "=2.0.1", - "lodash": "=3.10.1", - "sha512": "=0.0.1" + "lodash": "=3.10.1" }, "devDependencies": { "bitcore-build": "bitpay/bitcore-build",