Skip to main content

Compute HMAC-SHA1 hash (string.hmac_sha1)

Declaration

hex_hash = string.hmac_sha1(data, key)

Parameters

  • data
    string. Input data to hash.
  • key
    string. Secret key used by the HMAC algorithm.

Returns

  • hex_hash
    string. Lowercase hex text of the HMAC-SHA1 digest.

Description

Use the HMAC-SHA1 algorithm to compute a keyed hash for any string (or binary data).

Example

local signature = string.hmac_sha1('hello world', 'secret')
sys.alert(signature) -- prints "03376ee7ad7bbfceee98660439a4d8b125122a5a"

Note: Uses function outside of this chapter: sys.alert