From 61b981cf270153952a6cb8769abf67ea9275418d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 9 May 2023 23:56:51 +0000 Subject: [PATCH] crypto: remove default encoding from scrypt Refs: https://github.com/nodejs/node/pull/47182 --- lib/internal/crypto/scrypt.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index b794322c272840..a90d317c552331 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -28,7 +28,6 @@ const { const { getArrayBufferOrView, - getDefaultEncoding, } = require('internal/crypto/util'); const defaults = { @@ -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(); @@ -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) {