Skip to content

Commit

Permalink
crypto: remove default encoding from scrypt
Browse files Browse the repository at this point in the history
Refs: #47182
PR-URL: #47943
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
tniessen authored May 12, 2023
1 parent 6191dcf commit 2e67401
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {

const {
getArrayBufferOrView,
getDefaultEncoding,
} = require('internal/crypto/util');

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

const encoding = getDefaultEncoding();
job.ondone = (error, result) => {
if (error !== undefined)
return FunctionPrototypeCall(callback, job, error);
const buf = Buffer.from(result);
if (encoding === 'buffer')
return FunctionPrototypeCall(callback, job, null, buf);
FunctionPrototypeCall(callback, job, null, buf.toString(encoding));
return FunctionPrototypeCall(callback, job, null, buf);
};

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

const buf = Buffer.from(result);
const encoding = getDefaultEncoding();
return encoding === 'buffer' ? buf : buf.toString(encoding);
return Buffer.from(result);
}

function check(password, salt, keylen, options) {
Expand Down

0 comments on commit 2e67401

Please sign in to comment.