Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

WbString.hmac()

Perform a Hash-based Message Authentication Code on the input string

Syntax

WbString or JS Array = WbString.hmac(input_data, algorithm, key, format)

Parameters

The 'WbString.hmac' method takes 4 parameters:

Name Type/Value Range/Length Description
input_datastring  Required. Perform a hash function (eg MD5) on this data. Note this parameter may be either ad string or a Binary object
algorithmstring  Required. The hash to be used, eg 'MD5'
keystring  Required. The key to be used in the hash
formatstring  Optional, default = base64
The output format for the resulting string. Options:
  • base64
  • hex
  • bytes - the result is a Javascript array of byte values

Results

The 'WbString.hmac' 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.hmac(data,'MD5',key,'base64');

The first three parameters are mandatory.

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.

Whitebeam release 1.3.36
(loadtime : 19ms)