llHMAC

From Second Life Wiki
Revision as of 03:31, 7 May 2023 by Sei Lisa (talk | contribs) (If the input changes, so does the output)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: string llHMAC( string private_key, string msg, string algorithm );

Returns a string that is the "Wikipedia logo"Base64-encoded "Wikipedia logo"HMAC hash of msg when using hash algorithm algorithm and secret key private_key.

• string private_key
• string msg
• string algorithm

This function supports md5, sha1, sha224, sha256, sha384, sha512 for algorithm.

Examples

default
{
    state_entry()
    {
        string private_key = "secret key";
        
        // Supported algorithims for llHMAC() include:
        // md5, sha1, sha224, sha256, sha384, sha512
        
        string algorithm = "sha1";
        string msg = "Hello, Avatar!";
        
        string digest = llHMAC(private_key, msg, algorithm);
        
        // For the given private_key/msg/algorithm, expect the HMAC
        // digest to be 'ffCDntkagRO5mIEtd2tYzM2Bg8I='
        llSay(0, "HMAC digest of message '" + msg + "' using algorithm "
            +  algorithm + " is " + digest);
    }
}

See Also

Functions

•  llSignRSA
•  llVerifyRSA
•  llSHA1String
•  llSHA256String
•  llMD5String

Deep Notes

Search JIRA for related Issues

Signature

function string llHMAC( string private_key, string msg, string algorithm );