Difference between revisions of "LlHMAC"

From Second Life Wiki
Jump to navigation Jump to search
m (RSA key not needed for HMAC)
(If the input changes, so does the output)
 
Line 28: Line 28:
          
          
         // For the given private_key/msg/algorithm, expect the HMAC
         // For the given private_key/msg/algorithm, expect the HMAC
         // digest to be 'xK/3hcR1IVpVK9vftoztuVRGZFE='
         // digest to be 'ffCDntkagRO5mIEtd2tYzM2Bg8I='
         llSay(0, "HMAC digest of message '" + msg + "' using algorithm "
         llSay(0, "HMAC digest of message '" + msg + "' using algorithm "
             +  algorithm + " is " + digest);
             +  algorithm + " is " + digest);

Latest revision as of 02:31, 7 May 2023

Summary

Function: string llHMAC( string private_key, string msg, string algorithm );
0.0 Forced Delay
10.0 Energy

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

Signature

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