Skip to content
Permalink
Browse files

crypto: fix default encoding of LazyTransform

PullRequest nodejs#5522 and nodejs#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
Lukas Möller committed Sep 19, 2016
1 parent 74b56cd commit fe9de5d880ed0d6b22e70dd2d7f24e017f0bfdbb
Showing with 7 additions and 7 deletions.
  1. +7 −7 test/parallel/test-crypto.js
@@ -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();
@@ -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);
@@ -205,5 +205,5 @@ testEncoding({
}, assertionHashUtf8);

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

0 comments on commit fe9de5d

Please sign in to comment.
You can’t perform that action at this time.