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) {