Livecode Wiki

Compute a message authentication code.


messageAuthenticationCode(message, key, codeType)


  • message: A string.
  • key: A string.
  • codeType: The cryptographic hash function to use:
    • "HMAC-SHA3-224"
    • "HMAC-SHA3-256"
    • "HMAC-SHA3-384"
    • "HMAC-SHA3-512"
    • "HMAC-SHA-224"
    • "HMAC-SHA-256"
    • "HMAC-SHA-384"
    • "HMAC-SHA-512"
    • "HMAC-SHA-1": Use only for backwards compatibility
    • "HMAC-MD5": Use only for backwards compatibility


put messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256") into tHMAC
put base64encode(messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256"))
##this returns: KTofOJ9KkdZMMwULUkSxamYzH8wh7+UPDdFp5iaP1EQ=

messageAuthenticationCode provides a way to check the integrity of information transmitted over or stored in an unreliable medium is a prime necessity in the world of open computing and communications. Mechanisms that provide such integrity check based on a secret key are usually called "message authentication codes" (MAC). Typically, message authentication codes are used between two parties that share a secret key in order to validate information transmitted between these parties. messageAuthenticationCode also uses a secret key for calculation of the message authentication values.