HMAC()

Creates a hash-based message authentication code (HMAC) for the given message combined with a given secret key using an optional algorithm and encoding.

HMACs are used to verify the data integrity and authenticity of a transmitted message.

The hash function used by the HMAC function depends on the algorithm specified.

HMAC( message=object, key=object, algorithm=string, encoding=string );

Returns: String

Argument Description Default
message
object, required

The message to be hashed. Can be a string or a byte array.

key
object, required

The secret cryptographic key to be combined with the message and hashed. Can be a string or a byte array.

algorithm
string, optional

The algorithm to use for hashing your input. The following values are supported:

  • HmacMD5
  • HmacSHA1
  • HmacSHA256
  • HMACSHA384
  • HMACSHA512

HmacMD5

encoding
string, optional

The character encoding to use when converting the message to bytes. Must be a character encoding name recognized by the Java runtime.

  • utf-8
  • iso-8859-1
  • windows-1252
  • us-ascii
  • shift_jis
  • iso-2022-jp
  • euc-jp
  • euc-kr
  • big5
  • euc-cn
  • utf-16

Alias: charset

Examples

See also