Livecode Wiki
(Added example)
Tag: sourceedit
(⁹)
Tags: Visual edit Mobile web edit Mobile edit
 
Line 22: Line 22:
 
put messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256") into tHMAC
 
put messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256") into tHMAC
   
put base64encode(messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256"))
+
put base64encode(messageAuthenticationCode("My Data","My secret ","
  +
##this returns: KTofOJ9KkdZMMwULUkSxamYzH8wh7+UPDdFp5iaP1EQ=
 
  +
HMAC-SHA-256")
   
   

Latest revision as of 06:56, 26 March 2022

Compute a message authentication code.

Syntax

messageAuthenticationCode(message, key, codeType)

Parameters:

  • 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

Example

put messageAuthenticationCode("My Data", "My Secret", "HMAC-SHA-256") into tHMAC
put base64encode(messageAuthenticationCode("My Data","My secret ","

HMAC-SHA-256")


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.