diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js index 204ad456cd64b3..ab5746ce6a4cf8 100644 --- a/lib/internal/streams/lazy_transform.js +++ b/lib/internal/streams/lazy_transform.js @@ -23,11 +23,6 @@ function makeGetter(name) { return function() { stream.Transform.call(this, this._options); this._writableState.decodeStrings = false; - - if (!this._options || !this._options.defaultEncoding) { - this._writableState.defaultEncoding = 'buffer'; // TODO(tniessen): remove - } - return this[name]; }; } diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index a8ceb169de2b3d..8350401ba93707 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -298,6 +298,9 @@ function testEncoding(options, assertionHash) { let hashValue = ''; hash.on('data', (data) => { + // The defaultEncoding has no effect on the hash value. It only affects data + // consumed by the Hash transform stream. + assert(Buffer.isBuffer(data)); hashValue += data.toString('hex'); }); @@ -307,6 +310,8 @@ function testEncoding(options, assertionHash) { hash.write('öäü'); hash.end(); + + assert.strictEqual(hash._writableState.defaultEncoding, options?.defaultEncoding ?? 'utf8'); } // Hash of "öäü" in utf8 format