Difference between revisions of "32bit Hash"

From Second Life Wiki
Jump to navigation Jump to search
m (Change example according to LSL naming standard)
m (lsl code tagging)
Line 2: Line 2:
Here's a function to turn an UUID into an integer.
Here's a function to turn an UUID into an integer.


<pre>
<lsl>
integer Key2Integer(string inkey)
integer Key2Integer(string inkey)
{
{
     return (integer)("0x" + llGetSubString(llMD5String(inkey,0), 0, 7));   
     return (integer)("0x" + llGetSubString(llMD5String(inkey,0), 0, 7));   
}
}
</pre>
</lsl>


Note: The [[Seedable_PRNG]] example presents MD5 of MD5 of MD5 of ... as pseudo-random numbers
Note: The [[Seedable_PRNG]] example presents MD5 of MD5 of MD5 of ... as pseudo-random numbers


{{LSLC|Examples|32bit Hash}}
{{LSLC|Examples|32bit Hash}}

Revision as of 15:26, 30 March 2008

Here's a function to turn an UUID into an integer.

<lsl> integer Key2Integer(string inkey) {

   return (integer)("0x" + llGetSubString(llMD5String(inkey,0), 0, 7));   

} </lsl>

Note: The Seedable_PRNG example presents MD5 of MD5 of MD5 of ... as pseudo-random numbers