Verifying UUIDs

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Verifying UUIDs

Gordon Wendt
Hi, I'm sure this is something simple but for the life of me I haven't been able to find anything about it on the forum posts or the wiki so I figure I'll ask here.

Is there any way to verify that a given string is a UUID in addition to string length comparison since there are other strings that could also be 36 characters in length or is string length the only plausible way to verify that something is an actual UUID?

G.W.

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
Reply | Threaded
Open this post in threaded view
|

Re: Verifying UUIDs

Gordon Wendt
And incidentally I have checked the specification but since LL apparently doesn't follow it and I don't know how much and how specifically they've deviated the specification doesn't seem to be much help.

-G.W.

On Nov 29, 2007 4:18 AM, Gordon Wendt <[hidden email]> wrote:
Hi, I'm sure this is something simple but for the life of me I haven't been able to find anything about it on the forum posts or the wiki so I figure I'll ask here.

Is there any way to verify that a given string is a UUID in addition to string length comparison since there are other strings that could also be 36 characters in length or is string length the only plausible way to verify that something is an actual UUID?

G.W.


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
Reply | Threaded
Open this post in threaded view
|

Re: Verifying UUIDs

Phillip Lemon
In reply to this post by Gordon Wendt
IIRC, they are using V4 of the standard (random assignment)
http://en.wikipedia.org/wiki/UUID

There's a few mostly unreliable checks I can think of off the top of my head.

1) location and count of the hyphons.
2) strip numerals and check all characters are in the range a-f
3) calculate all 3.4x10^38 valid UUID's and confirm your string is in the list.

Note: 3 is likely 100% reliable but has a few minor technical issues,
perhaps the most serious is the heat death of the universe before the
function returns,  nothing serious though.

Amor / Phill

On Nov 29, 2007 4:18 AM, Gordon Wendt <[hidden email]> wrote:

> Hi, I'm sure this is something simple but for the life of me I haven't been
> able to find anything about it on the forum posts or the wiki so I figure
> I'll ask here.
>
> Is there any way to verify that a given string is a UUID in addition to
> string length comparison since there are other strings that could also be 36
> characters in length or is string length the only plausible way to verify
> that something is an actual UUID?
>
> G.W.
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>
>
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
Reply | Threaded
Open this post in threaded view
|

Re: Verifying UUIDs

virtuosic-bytes.com
In reply to this post by Gordon Wendt
In LSL it's easy:

checkKey(key k)
{
    if(k) llSay(0, "'" + (string)k + "' is a valid key");
    else llSay(0, "'" + (string)k + "' is NOT a valid key");
}

default
{
    state_entry()
    {
       key FooBar = "FOOBAR";
       key ObjKey = llGetKey();
       checkKey(FooBar);
       checkKey(ObjKey);
    }
}

Regards,
Virtouse
_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
Reply | Threaded
Open this post in threaded view
|

Re: Verifying UUIDs

virtuosic-bytes.com
Well you should also check if the key is a NULL_KEY, because NULL_KEY
results in false too for this check.
Regards,
Virtouse

virtuosic-bytes.com schrieb:

> In LSL it's easy:
>
> checkKey(key k)
> {
>    if(k) llSay(0, "'" + (string)k + "' is a valid key");
>    else llSay(0, "'" + (string)k + "' is NOT a valid key");
> }
>
> default
> {
>    state_entry()
>    {
>       key FooBar = "FOOBAR";
>       key ObjKey = llGetKey();
>       checkKey(FooBar);
>       checkKey(ObjKey);
>    }
> }
>
> Regards,
> Virtouse
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters

_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
Reply | Threaded
Open this post in threaded view
|

Re: Verifying UUIDs

Harleen Gretzky
This is Strife Onizuka's code from
http://lslwiki.net/lslwiki/wakka.php?wakka=key:

string null_key = NULL_KEY;

integer isKey(key in)
{//by: Strife Onizuka
    if(in) return 2;          // key is valid AND not equal NULL_KEY; the
distinction is important in some cases (return value of 2 is still evaluated
as unary boolean TRUE)
    return (in == null_key);  // key is valid AND equal to NULL_KEY (return
1 or TRUE), or is not valid (return 0 or FALSE)
}

key forceKey(key in)
{//force a string or key to be a valid key assuming you want invalids to
become NULL_KEY
    if(in) return in;
    return null_key;
}

----- Original Message -----
From: "virtuosic-bytes.com" <[hidden email]>
To: "Scripters" <[hidden email]>
Sent: Thursday, November 29, 2007 5:06 AM
Subject: Re: Verifying UUIDs


> Well you should also check if the key is a NULL_KEY, because NULL_KEY
> results in false too for this check.
> Regards,
> Virtouse
>
> virtuosic-bytes.com schrieb:
>> In LSL it's easy:
>>
>> checkKey(key k)
>> {
>>    if(k) llSay(0, "'" + (string)k + "' is a valid key");
>>    else llSay(0, "'" + (string)k + "' is NOT a valid key");
>> }
>>
>> default
>> {
>>    state_entry()
>>    {
>>       key FooBar = "FOOBAR";
>>       key ObjKey = llGetKey();
>>       checkKey(FooBar);
>>       checkKey(ObjKey);
>>    }
>> }
>>
>> Regards,
>> Virtouse
>> _______________________________________________
>> Click here to unsubscribe or manage your list subscription:
>> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters
>


_______________________________________________
Click here to unsubscribe or manage your list subscription:
https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters