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
squash
  • Loading branch information
Trott committed Oct 27, 2017
commit 072086ce2a32fc7325939e1b951099e1c07a4279
20 changes: 12 additions & 8 deletions test/parallel/test-crypto-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,26 @@ a8 = a8.read();

if (!common.hasFipsCrypto) {
cryptoType = 'md5';
digest = 'latin1'
digest = 'latin1';
const a0 = crypto.createHash(cryptoType).update('Test123').digest(digest);
assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
`${cryptoType} with ${digest} digest failed to evaluate to expected hash value.`
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`
);
}
cryptoType = 'md5';
digest = 'hex';
assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2',
`${cryptoType} with ${digest} digest failed to evaluate to expected hash value.`);
assert.strictEqual(
a1,
'8308651804facb7b9af8ffc53a33a22d6a1c8ac2',
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
cryptoType = 'sha256';
digest = 'base64';
assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
`${cryptoType} with ${digest} digest failed to evaluate to expected hash value.`);
assert.strictEqual(
a2,
'2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
cryptoType = 'sha512';
digest = 'latin1';
assert.deepStrictEqual(
Expand All @@ -68,13 +72,13 @@ assert.deepStrictEqual(
'\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' +
'\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'',
'latin1'),
`${cryptoType} with ${digest} digest failed to evaluate to expected hash value.`);
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
cryptoType = 'sha1';
digest = 'hex';
assert.deepStrictEqual(
a4,
Buffer.from('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex'),
`${cryptoType} with ${digest} digest failed to evaluate to expected hash value.`
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`
);

// stream interface should produce the same result.
Expand Down