llGenerateKey

From Second Life Wiki
Revision as of 11:05, 2 September 2008 by Haravikk Mistral (talk | contribs) (New page: {{LSL_Function |func=generateKey |func_desc=Generates a key using Type 3 (MD5) UUID generation to create a unique key using region-name, object-key, service and variable. |return_type=key ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: key generateKey( string service, string variable );

Generates a key using Type 3 (MD5) UUID generation to create a unique key using region-name, object-key, service and variable.
Returns a key The generated key

• string service The service, object, function, or whatever else this key may represent.
• string variable Any variable(s) relevant to the service that uniquely distinguish it.

Examples

key timeKey = generateKey("time", (string)llGetUnixTime());

Implementation

<lsl>key generateKey(string service, string variable) {

   return (key)llInsertString(
       llInsertString(
           llInsertString(
               llInsertString(
                   llMD5String(
                       "secondlife://" + llGetRegionName()  + "/" + 
                       (string)llGetKey() + "/" + service + "/" + 
                       variable, 
                       0 // This is reserved by specification, will 
                         // be increased with new/different versions.
                   ),
                   8,
                   "-"
               ),
               13,
               "-"
           ),
           18,
           "-"
       ),
       23,
       "-"
   );

}</lsl>