[Pkg-javascript-commits] [node-sha.js] 23/31: Buffer: use alloc/allocUnsafe/from instead new

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 30 11:23:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-sha.js.

commit 100edf9c567e1e1079dc1d6d7c7725a0644e425c
Author: Kirill Fomichev <fanatid at ya.ru>
Date:   Mon Sep 25 16:47:18 2017 +0300

    Buffer: use alloc/allocUnsafe/from instead new
---
 hash.js   | 4 ++--
 sha.js    | 2 +-
 sha1.js   | 2 +-
 sha224.js | 2 +-
 sha256.js | 2 +-
 sha384.js | 2 +-
 sha512.js | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hash.js b/hash.js
index 3d0e08e..f7cbd07 100644
--- a/hash.js
+++ b/hash.js
@@ -2,7 +2,7 @@ var Buffer = require('safe-buffer').Buffer
 
 // prototype class for hash functions
 function Hash (blockSize, finalSize) {
-  this._block = new Buffer(blockSize)
+  this._block = Buffer.alloc(blockSize)
   this._finalSize = finalSize
   this._blockSize = blockSize
   this._len = 0
@@ -11,7 +11,7 @@ function Hash (blockSize, finalSize) {
 Hash.prototype.update = function (data, enc) {
   if (typeof data === 'string') {
     enc = enc || 'utf8'
-    data = new Buffer(data, enc)
+    data = Buffer.from(data, enc)
   }
 
   var block = this._block
diff --git a/sha.js b/sha.js
index 2e27cd8..50c4fa8 100644
--- a/sha.js
+++ b/sha.js
@@ -80,7 +80,7 @@ Sha.prototype._update = function (M) {
 }
 
 Sha.prototype._hash = function () {
-  var H = new Buffer(20)
+  var H = Buffer.allocUnsafe(20)
 
   H.writeInt32BE(this._a | 0, 0)
   H.writeInt32BE(this._b | 0, 4)
diff --git a/sha1.js b/sha1.js
index dfacb4b..cabd747 100644
--- a/sha1.js
+++ b/sha1.js
@@ -85,7 +85,7 @@ Sha1.prototype._update = function (M) {
 }
 
 Sha1.prototype._hash = function () {
-  var H = new Buffer(20)
+  var H = Buffer.allocUnsafe(20)
 
   H.writeInt32BE(this._a | 0, 0)
   H.writeInt32BE(this._b | 0, 4)
diff --git a/sha224.js b/sha224.js
index 37bf85c..35541e5 100644
--- a/sha224.js
+++ b/sha224.js
@@ -37,7 +37,7 @@ Sha224.prototype.init = function () {
 }
 
 Sha224.prototype._hash = function () {
-  var H = new Buffer(28)
+  var H = Buffer.allocUnsafe(28)
 
   H.writeInt32BE(this._a, 0)
   H.writeInt32BE(this._b, 4)
diff --git a/sha256.js b/sha256.js
index 9afce95..342e48a 100644
--- a/sha256.js
+++ b/sha256.js
@@ -118,7 +118,7 @@ Sha256.prototype._update = function (M) {
 }
 
 Sha256.prototype._hash = function () {
-  var H = new Buffer(32)
+  var H = Buffer.allocUnsafe(32)
 
   H.writeInt32BE(this._a, 0)
   H.writeInt32BE(this._b, 4)
diff --git a/sha384.js b/sha384.js
index 8435b40..afc85e5 100644
--- a/sha384.js
+++ b/sha384.js
@@ -37,7 +37,7 @@ Sha384.prototype.init = function () {
 }
 
 Sha384.prototype._hash = function () {
-  var H = new Buffer(48)
+  var H = Buffer.allocUnsafe(48)
 
   function writeInt64BE (h, l, offset) {
     H.writeInt32BE(h, offset)
diff --git a/sha512.js b/sha512.js
index 07431af..fb28f2f 100644
--- a/sha512.js
+++ b/sha512.js
@@ -238,7 +238,7 @@ Sha512.prototype._update = function (M) {
 }
 
 Sha512.prototype._hash = function () {
-  var H = new Buffer(64)
+  var H = Buffer.allocUnsafe(64)
 
   function writeInt64BE (h, l, offset) {
     H.writeInt32BE(h, offset)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git



More information about the Pkg-javascript-commits mailing list