From 948f94de68479deada6f17511aa7f5c1e70deb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 5 May 2023 00:25:17 +0000 Subject: [PATCH] crypto: remove default encoding from pbkdf2 Refs: https://github.com/nodejs/node/pull/47182 --- 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) {