Fun Project: xTalk GUID Generator

Mark Smith mark at maseurope.net
Fri Dec 1 16:40:08 EST 2006


On 1 Dec 2006, at 20:17, Bill Marriott wrote:

>
> Now, several posts later we still don't have an xTalk GUID  
> generator! -LOL-
> Is anyone up to the task? Or at least able to translate all the  
> language in
> that RFC?
>

This my type 4 generator, based on the idea that 122 random bits is  
no different to 60 + 14 + 48 random bits.

function getRandomUUID
   repeat 128
     put random(2) - 1 after tBits
   end repeat

   put "0100" into char 49 to 51 of tBits
   put "10" into char 79 to 80 of tBits

    repeat with n = 1 to 125 step 4
     put baseConvert(char n to n+3 of tBits,2,16) after tHexString
   end repeat

   put "-" after char 20 of tHexString
   put "-" after char 16 of tHexString
   put "-" after char 12 of tHexString
   put "-" after char 8 of tHexString

   return tHexString
end getRandomUUID

I suspect it's not really bona-fide :)

Mark



More information about the Use-livecode mailing list