Re: generating random id's
| From: | Dan Baker | Date: | Thu, 09 Feb 2006 17:08:14 +0000 |
| Subject: | Re: generating random id's | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41205@lists.php.net to get a copy of this message | ||
"JeRRy" <jusa_98@yahoo.com> wrote in message
news:20060209072645.46008.qmail@web34806.mail.mud.yahoo.com...
>
> Just to let you all know I used PHP's unique ID generator to generate a
> unique id for tracking purposes.
> I than md5 it hide the format a bit, would this be enough?
> Or can be easily worked out also?
> Need it pretty tight and keeping the likelyhood down of having multiple
> listings of id's.
> It's using 32 chars.
So, I'm guessing/interpreting here:
You have a table that has records in it, each record has a unique ID (an
auto-increment field).
You want to be able to send some magic ID with an html page, so that you can
identify the record when the page response comes back. But, you don't want
the end-user to easily alter the ID to discover a different record.
Now, I don't have a clear understanding of what you have doe with the "32
char" item:
Idea #1) You have added another field "RndID" which you generate for each
record, and use this as the published record ID.
Idea #2) You take the ID, and mangle it, and use the mangled ID as the
published record ID. When it comes back, you un-mangle it to get the true
ID.
I've used idea #1 before. I set the RndID field as "Unique", so I never
have duplicates. If the record update fails, I generate a different random
ID and try again.
I've never used idea#2.
DanB