зеркало из https://github.com/github/blakejs.git
use Buffer.from, new Buffer() is deprecated
This commit is contained in:
Родитель
518b468b17
Коммит
72c457956f
|
@ -26,7 +26,7 @@ test('Input types', function (t) {
|
|||
// Supports string, Uint8Array, and Buffer inputs
|
||||
// We already verify that blake2bHex('abc') produces the correct hash above
|
||||
t.equal(blake2bHex(new Uint8Array([97, 98, 99])), blake2bHex('abc'))
|
||||
t.equal(blake2bHex(new Buffer([97, 98, 99])), blake2bHex('abc'))
|
||||
t.equal(blake2bHex(Buffer.from([97, 98, 99])), blake2bHex('abc'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ test('BLAKE2s basic', function (t) {
|
|||
'508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')
|
||||
t.equal(blake2sHex(new Uint8Array([97, 98, 99])),
|
||||
'508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')
|
||||
t.equal(blake2sHex(new Buffer([97, 98, 99])),
|
||||
t.equal(blake2sHex(Buffer.from([97, 98, 99])),
|
||||
'508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')
|
||||
t.end()
|
||||
})
|
||||
|
|
2
util.js
2
util.js
|
@ -8,7 +8,7 @@ function normalizeInput (input) {
|
|||
} else if (input instanceof Buffer) {
|
||||
ret = new Uint8Array(input)
|
||||
} else if (typeof (input) === 'string') {
|
||||
ret = new Uint8Array(new Buffer(input, 'utf8'))
|
||||
ret = new Uint8Array(Buffer.from(input, 'utf8'))
|
||||
} else {
|
||||
throw new Error(ERROR_MSG_INPUT)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче