File tree Expand file tree Collapse file tree 7 files changed +8
-8
lines changed Expand file tree Collapse file tree 7 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ var Buffer = require('safe-buffer').Buffer
2
2
3
3
// prototype class for hash functions
4
4
function Hash ( blockSize , finalSize ) {
5
- this . _block = new Buffer ( blockSize )
5
+ this . _block = Buffer . alloc ( blockSize )
6
6
this . _finalSize = finalSize
7
7
this . _blockSize = blockSize
8
8
this . _len = 0
@@ -11,7 +11,7 @@ function Hash (blockSize, finalSize) {
11
11
Hash . prototype . update = function ( data , enc ) {
12
12
if ( typeof data === 'string' ) {
13
13
enc = enc || 'utf8'
14
- data = new Buffer ( data , enc )
14
+ data = Buffer . from ( data , enc )
15
15
}
16
16
17
17
var block = this . _block
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ Sha.prototype._update = function (M) {
80
80
}
81
81
82
82
Sha . prototype . _hash = function ( ) {
83
- var H = new Buffer ( 20 )
83
+ var H = Buffer . allocUnsafe ( 20 )
84
84
85
85
H . writeInt32BE ( this . _a | 0 , 0 )
86
86
H . writeInt32BE ( this . _b | 0 , 4 )
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ Sha1.prototype._update = function (M) {
85
85
}
86
86
87
87
Sha1 . prototype . _hash = function ( ) {
88
- var H = new Buffer ( 20 )
88
+ var H = Buffer . allocUnsafe ( 20 )
89
89
90
90
H . writeInt32BE ( this . _a | 0 , 0 )
91
91
H . writeInt32BE ( this . _b | 0 , 4 )
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ Sha224.prototype.init = function () {
37
37
}
38
38
39
39
Sha224 . prototype . _hash = function ( ) {
40
- var H = new Buffer ( 28 )
40
+ var H = Buffer . allocUnsafe ( 28 )
41
41
42
42
H . writeInt32BE ( this . _a , 0 )
43
43
H . writeInt32BE ( this . _b , 4 )
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ Sha256.prototype._update = function (M) {
118
118
}
119
119
120
120
Sha256 . prototype . _hash = function ( ) {
121
- var H = new Buffer ( 32 )
121
+ var H = Buffer . allocUnsafe ( 32 )
122
122
123
123
H . writeInt32BE ( this . _a , 0 )
124
124
H . writeInt32BE ( this . _b , 4 )
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ Sha384.prototype.init = function () {
37
37
}
38
38
39
39
Sha384 . prototype . _hash = function ( ) {
40
- var H = new Buffer ( 48 )
40
+ var H = Buffer . allocUnsafe ( 48 )
41
41
42
42
function writeInt64BE ( h , l , offset ) {
43
43
H . writeInt32BE ( h , offset )
Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ Sha512.prototype._update = function (M) {
238
238
}
239
239
240
240
Sha512 . prototype . _hash = function ( ) {
241
- var H = new Buffer ( 64 )
241
+ var H = Buffer . allocUnsafe ( 64 )
242
242
243
243
function writeInt64BE ( h , l , offset ) {
244
244
H . writeInt32BE ( h , offset )
You can’t perform that action at this time.
0 commit comments