Method Description
WbString.hmac2()
Perform a Hash-based Message Authentication Code on the input string
Syntax
WbString or JS Array = WbString.hmac2(input_data, algorithm, options)
Parameters
The 'WbString.hmac2' method takes 3 parameters:
Name | Type/Value | Range/Length | Description | input_data | string | | Required. Perform a hash function (eg MD5) on this data. Note this parameter may be either and string or a Binary object | algorithm | string | | Required. The hash to be used, eg 'MD5' | options | struct WbString.Options | see definition | Required. Switches |
Results
The 'WbString.hmac2' method returns WbString or JS Array:
Type/Value | Range/Length | Description |
WbString or JS Array |
  |
Returns the suitably encoded version of the selected hash
|
Remarks This method takes an input parameter which may be either an instance of a
Binary object
or a String (or another value that will be converted to a string). Note: This is a class method on WbString and so is
invoked as WbString.hmac2(data,'MD5',{key:my_key,outputFmt:'base64'}); All parameters are required. The algorithm is expressed as a string. The method makes use of the system installed openSSL library and values that may
be passed to this parameter will be determined by the library you have installed. Values include: - MD4
- MD5
- SHA
- SHA1
- SHA256
- DSS1
- RIPEMD160
Strings are not case sensitive. The method will take the data and produce a hash using the selected algorithm using the specified key. If the algorithm is
not known then Whitebeam will throw a catchable error. The hash generated is effectively an n-bit string, the length depending on the chosen algorithm. This hash value can be returned
to the application in one of 3 formats. By default the returned value will be a base-64 encoded string. The full list of output
encodings are: - base64 (default)
- hex
- bytes - the result is a Javascript array of byte values
The first two formats return a WbString. The last returns a Javascript Array with each subscript being 8 bits of the key. |