Skip to content

Commit fe9de5d

Browse files
author
Lukas Möller
committed
crypto: fix default encoding of LazyTransform
PullRequest #5522 and #5500 described the change of the default encoding into UTF8 in crypto functions. This however was only changed for the non-streaming API. The streaming API still used binary as the default encoding. This commit will change the default streaming API encoding to UTF8 to make both APIs behave the same. It will also add tests to validate the behavior.
1 parent 74b56cd commit fe9de5d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-crypto.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ function testEncoding(options, assertionHash) {
181181
hashValue += data.toString('hex');
182182
});
183183

184-
hash.on('end', () => {
185-
assert.equal(hashValue, assertionHash);
186-
});
184+
hash.on('end', common.mustCall(() => {
185+
assert.strictEqual(hashValue, assertionHash);
186+
}));
187187

188188
hash.write('öäü');
189189
hash.end();
@@ -193,8 +193,8 @@ function testEncoding(options, assertionHash) {
193193
const assertionHashUtf8 =
194194
'4f53d15bee524f082380e6d7247cc541e7cb0d10c64efdcc935ceeb1e7ea345c';
195195

196-
// Hash of "öäü" in ascii format
197-
const assertionHashAscii =
196+
// Hash of "öäü" in latin1 format
197+
const assertionHashLatin1 =
198198
'cd37bccd5786e2e76d9b18c871e919e6eb11cc12d868f5ae41c40ccff8e44830';
199199

200200
testEncoding(undefined, assertionHashUtf8);
@@ -205,5 +205,5 @@ testEncoding({
205205
}, assertionHashUtf8);
206206

207207
testEncoding({
208-
defaultEncoding: 'ascii'
209-
}, assertionHashAscii);
208+
defaultEncoding: 'latin1'
209+
}, assertionHashLatin1);

0 commit comments

Comments
 (0)