@@ -9,6 +9,9 @@ const fs = require('fs');
99
1010const  fixtures  =  require ( '../common/fixtures' ) ; 
1111
12+ let  cryptoType ; 
13+ let  digest ; 
14+ 
1215// Test hashing 
1316const  a1  =  crypto . createHash ( 'sha1' ) . update ( 'Test123' ) . digest ( 'hex' ) ; 
1417const  a2  =  crypto . createHash ( 'sha256' ) . update ( 'Test123' ) . digest ( 'base64' ) ; 
@@ -37,16 +40,29 @@ a8.end();
3740a8  =  a8 . read ( ) ; 
3841
3942if  ( ! common . hasFipsCrypto )  { 
40-   const  a0  =  crypto . createHash ( 'md5' ) . update ( 'Test123' ) . digest ( 'latin1' ) ; 
43+   cryptoType  =  'md5' ; 
44+   digest  =  'latin1' ; 
45+   const  a0  =  crypto . createHash ( cryptoType ) . update ( 'Test123' ) . digest ( digest ) ; 
4146  assert . strictEqual ( 
4247    a0 , 
4348    'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c' , 
44-     'Test MD5 as latin1' 
49+     ` ${ cryptoType }  with  ${ digest }  digest failed to evaluate to expected hash` 
4550  ) ; 
4651} 
47- assert . strictEqual ( a1 ,  '8308651804facb7b9af8ffc53a33a22d6a1c8ac2' ,  'Test SHA1' ) ; 
48- assert . strictEqual ( a2 ,  '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=' , 
49-                    'Test SHA256 as base64' ) ; 
52+ cryptoType  =  'md5' ; 
53+ digest  =  'hex' ; 
54+ assert . strictEqual ( 
55+   a1 , 
56+   '8308651804facb7b9af8ffc53a33a22d6a1c8ac2' , 
57+   `${ cryptoType } ${ digest }  ) ; 
58+ cryptoType  =  'sha256' ; 
59+ digest  =  'base64' ; 
60+ assert . strictEqual ( 
61+   a2 , 
62+   '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=' , 
63+   `${ cryptoType } ${ digest }  ) ; 
64+ cryptoType  =  'sha512' ; 
65+ digest  =  'latin1' ; 
5066assert . deepStrictEqual ( 
5167  a3 , 
5268  Buffer . from ( 
@@ -56,11 +72,13 @@ assert.deepStrictEqual(
5672    '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093'  + 
5773    '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'' , 
5874    'latin1' ) , 
59-   'Test SHA512 as assumed buffer' ) ; 
75+   `${ cryptoType } ${ digest }  ) ; 
76+ cryptoType  =  'sha1' ; 
77+ digest  =  'hex' ; 
6078assert . deepStrictEqual ( 
6179  a4 , 
6280  Buffer . from ( '8308651804facb7b9af8ffc53a33a22d6a1c8ac2' ,  'hex' ) , 
63-   'Test SHA1' 
81+   ` ${ cryptoType }  with  ${ digest }  digest failed to evaluate to expected hash` 
6482) ; 
6583
6684// stream interface should produce the same result. 
0 commit comments