Skip to content

Commit

Permalink
crypto: fix default encoding of LazyTransform
Browse files Browse the repository at this point in the history
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
1 parent 74b56cd commit fe9de5d
Showing 1 changed file with 7 additions and 7 deletions.
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);

0 comments on commit fe9de5d

Please sign in to comment.