Methods
(static) createMd5Hash(data) → {string}
Convenient function to create md5 hash from string.
Parameters:
Name | Type | Description |
---|---|---|
data |
* |
Returns:
md5 hash
- Type
- string
(static) hashHmac(algorithm, data, secret) → {string}
Equivalent to PHP's hash_hmac
function.
Parameters:
Name | Type | Description |
---|---|---|
algorithm |
string | hashing algorithm |
data |
* | data string to be hashed |
secret |
Buffer | Secret key used to hash data, generated with |
Returns:
digested hash
- Type
- string
(static) pack(data, encoding) → {Buffer}
Equivalent to PHP's pack
function, using Node native Buffer
Note: PHP
pack('H*', data)
is equivalent to Node:
Buffer.from(data, 'hex')
Parameters:
Name | Type | Description |
---|---|---|
data |
* | |
encoding |
* |
Returns:
Buffer of data encoded with encoding
method
- Type
- Buffer
(static) to2DigitNumber(number) → {string}
Convenient function to convert number to 2 digit number string
Parameters:
Name | Type | Description |
---|---|---|
number |
* |
Returns:
formatted number
- Type
- string
(static) toUpperCase(s) → {string}
Global function to convert String to upper case, with type checking
Parameters:
Name | Type | Description |
---|---|---|
s |
string |
Returns:
all upper case string
- Type
- string
(static) vnPayDateFormat(date) → {string}
Convenient function to convert date to format yyyyMMddHHmmss
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | Date object that need to be formatted |
Returns:
date string formatted in yyyyMMddHHmmss
- Type
- string