"Brian Menke" <[EMAIL PROTECTED]> wrote on 02/12/2006 09:20:32 PM:

> I have a table with about 2000 entries with names and other data. 
Ultimately
> I'm going to make a database backed web site with this and I want to 
provide
> existing users with random id's that they will use for their passwords. 
I
> was wondering how to take the existing data and add random id's to it. 
This
> web site will be using PHP as the programming language so it would be 
nice
> if I could use the same mechanism to add the random id's automatically 
when
> I add new users via a web form.
> 
> 
> 
> 
> 
> Thanks for any ideas on how to approach this!
> 
> 
> 
> -Brian Menke
> 

One simple method could be to add another column to your existing users 
table and fill it with a hashed/encrypted copy of the plain-old 
auto_increment value already on the table:

ALTER TABLE userstable ADD idhash varchar(25);

UPDATE userstable set idhash = OLD_PASSWORD(id);

It's not pretty, but it's quick. RTFM for more details on the available 
encryption/data hashing functions.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to