Skip to content

Commit d799347

Browse files
tniessentargos
authored andcommitted
crypto: remove default encoding from scrypt
Refs: #47182 PR-URL: #47943 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6f5ba92 commit d799347

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/internal/crypto/scrypt.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const {
2828

2929
const {
3030
getArrayBufferOrView,
31-
getDefaultEncoding,
3231
} = require('internal/crypto/util');
3332

3433
const defaults = {
@@ -53,14 +52,11 @@ function scrypt(password, salt, keylen, options, callback = defaults) {
5352
const job = new ScryptJob(
5453
kCryptoJobAsync, password, salt, N, r, p, maxmem, keylen);
5554

56-
const encoding = getDefaultEncoding();
5755
job.ondone = (error, result) => {
5856
if (error !== undefined)
5957
return FunctionPrototypeCall(callback, job, error);
6058
const buf = Buffer.from(result);
61-
if (encoding === 'buffer')
62-
return FunctionPrototypeCall(callback, job, null, buf);
63-
FunctionPrototypeCall(callback, job, null, buf.toString(encoding));
59+
return FunctionPrototypeCall(callback, job, null, buf);
6460
};
6561

6662
job.run();
@@ -77,9 +73,7 @@ function scryptSync(password, salt, keylen, options = defaults) {
7773
if (err !== undefined)
7874
throw err;
7975

80-
const buf = Buffer.from(result);
81-
const encoding = getDefaultEncoding();
82-
return encoding === 'buffer' ? buf : buf.toString(encoding);
76+
return Buffer.from(result);
8377
}
8478

8579
function check(password, salt, keylen, options) {

0 commit comments

Comments
 (0)