-
-
Notifications
You must be signed in to change notification settings - Fork 44
hash.js
- Hash
-
Crypto hash functions utils. Specification
Crypto hash functions utils. Specification
Kind: global class
-
Hash
-
.md5(thing, [key], [agency]) ⇒
string -
.hmac(thing, key, [algorithm]) ⇒
string .hmacSha256(thing, key) ⇒string-
.sha1(thing) ⇒
string -
.sha256(thing) ⇒
string -
.equals(known, [user]) ⇒
boolean -
.sign(type, data, key) ⇒
string
-
.md5(thing, [key], [agency]) ⇒
Calculate the input string with an optional secret key in MD5,
when the key is Falsey, this method works as normal MD5.
- [agency] is available {@since v0.4.3}, spec
Kind: static method of Hash
Returns: string - - data signature
| Param | Type | Default | Description |
|---|---|---|---|
| thing |
string | Buffer
|
The input string. | |
| [key] | string |
The secret key string. | |
| [agency] |
boolean | number | string
|
false |
The secret key is from wework, placed with true or better of the AgentId value. |
Calculate the input string with a secret key as of algorithm string which is one of the 'sha256', 'sha512' etc.
Kind: static method of Hash
Returns: string - - data signature
| Param | Type | Default | Description |
|---|---|---|---|
| thing |
string | Buffer
|
The input string. | |
| key | string |
The secret key string. | |
| [algorithm] | string |
"sha256" |
The algorithm string, default is sha256. |
Deprecated
Kind: static method of Hash
Returns: string - - data signature
| Param | Type | Description |
|---|---|---|
| thing |
string | Buffer
|
The input string. |
| key | string |
The secret key string. |
Calculate the input in SHA1.
Kind: static method of Hash
Returns: string - - data signature
| Param | Type | Description |
|---|---|---|
| thing |
string | Buffer
|
The input. |
Calculate the input in SHA256.
Kind: static method of Hash
Returns: string - - data signature
| Param | Type | Description |
|---|---|---|
| thing |
string | Buffer
|
The input. |
Wrapping the builtins crypto.timingSafeEqual function.
Kind: static method of Hash
Returns: boolean - - Returns true when the two are equal, false otherwise.
| Param | Type | Description |
|---|---|---|
| known | string |
The string of known length to compare against. |
| [user] | string |
The user-supplied string. |
Utils of the data signature calculation.
Kind: static method of Hash
Returns: string - - The data signature.
| Param | Type | Description |
|---|---|---|
| type | string |
The sign type, one of the MD5 or HMAC-SHA256. |
| data | object |
The input data. |
| key | string |
The secret key string. |
Kind: global constant