| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 35d492c commit a407a48
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,3 +154,10 @@ common.expectsError( | |||
| 154 | 154 | message: 'The "algorithm" argument must be of type string' | |
| 155 | 155 | } | |
| 156 | 156 | ); | |
| 157 | + | ||
| 158 | + { | ||
| 159 | + const Hash = crypto.Hash; | ||
| 160 | + const instance = crypto.Hash('sha256'); | ||
| 161 | + assert(instance instanceof Hash, 'Hash is expected to return a new instance' + | ||
| 162 | + ' when called without `new`'); | ||
| 163 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,30 @@ if (!common.hasCrypto) | |||
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const crypto = require('crypto'); | |
| 8 | 8 | ||
| 9 | + { | ||
| 10 | + const Hmac = crypto.Hmac; | ||
| 11 | + const instance = crypto.Hmac('sha256', 'Node'); | ||
| 12 | + assert(instance instanceof Hmac, 'Hmac is expected to return a new instance' + | ||
| 13 | + ' when called without `new`'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + common.expectsError( | ||
| 17 | + () => crypto.createHmac(null), | ||
| 18 | + { | ||
| 19 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 20 | + type: TypeError, | ||
| 21 | + message: 'The "hmac" argument must be of type string' | ||
| 22 | + }); | ||
| 23 | + | ||
| 24 | + common.expectsError( | ||
| 25 | + () => crypto.createHmac('sha1', null), | ||
| 26 | + { | ||
| 27 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 28 | + type: TypeError, | ||
| 29 | + message: 'The "key" argument must be one of type string, TypedArray, or ' + | ||
| 30 | + 'DataView' | ||
| 31 | + }); | ||
| 32 | + | ||
| 9 | 33 | { | |
| 10 | 34 | // Test HMAC | |
| 11 | 35 | const actual = crypto.createHmac('sha1', 'Node') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments