From e9c6ee74f3b23a03e302df5177dc8ee7025f0a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 7 May 2023 02:49:59 +0200 Subject: [PATCH] crypto: remove default encoding from pbkdf2 Refs: https://github.com/nodejs/node/pull/47182 PR-URL: https://github.com/nodejs/node/pull/47869 Reviewed-By: Filip Skokan Reviewed-By: Luigi Pinca --- lib/internal/crypto/pbkdf2.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index a46d5120236fba..697ceffa542aa7 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -20,7 +20,6 @@ const { const { getArrayBufferOrView, - getDefaultEncoding, normalizeHashName, kKeyObject, } = require('internal/crypto/util'); @@ -49,14 +48,11 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) { keylen, digest); - const encoding = getDefaultEncoding(); job.ondone = (err, result) => { if (err !== undefined) return FunctionPrototypeCall(callback, job, err); 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(); @@ -78,9 +74,7 @@ function pbkdf2Sync(password, salt, iterations, keylen, digest) { 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, iterations, keylen, digest) {