Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
Lukas Möller committed Feb 16, 2017
commit fe9de5d880ed0d6b22e70dd2d7f24e017f0bfdbb
14 changes: 7 additions & 7 deletions test/parallel/test-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ function testEncoding(options, assertionHash) {
hashValue += data.toString('hex');
});

hash.on('end', () => {
assert.equal(hashValue, assertionHash);
});
hash.on('end', common.mustCall(() => {
assert.strictEqual(hashValue, assertionHash);
}));

hash.write('öäü');
hash.end();
Expand All @@ -193,8 +193,8 @@ function testEncoding(options, assertionHash) {
const assertionHashUtf8 =
'4f53d15bee524f082380e6d7247cc541e7cb0d10c64efdcc935ceeb1e7ea345c';

// Hash of "öäü" in ascii format
const assertionHashAscii =
// Hash of "öäü" in latin1 format
const assertionHashLatin1 =
'cd37bccd5786e2e76d9b18c871e919e6eb11cc12d868f5ae41c40ccff8e44830';

testEncoding(undefined, assertionHashUtf8);
Expand All @@ -205,5 +205,5 @@ testEncoding({
}, assertionHashUtf8);

testEncoding({
defaultEncoding: 'ascii'
}, assertionHashAscii);
defaultEncoding: 'latin1'
}, assertionHashLatin1);