mysql random generated value
Posted
by bbutle01
on Stack Overflow
See other posts from Stack Overflow
or by bbutle01
Published on 2009-02-12T15:21:37Z
Indexed on
2010/04/14
5:53 UTC
Read the original article
Hit count: 353
mysql
I need to generate a random alpha/numeric to give to users that they come to the site to enter. I dont' know much about random numbers and such, I know there are seeding issues and such, but I'm not sure what they are.
So, I used this:
select substrING(md5(concat_ws('-',md5(username_usr), MD5(zip_usr), MD5(id_usr), MD5(created_usr))),-12) from users_usr
Is this safe? I used concat_ws because sometimes zip is null, but the others never are.
And yes, I know this is kinda short, but 1. They have to enter the last 4 of their social, 2. It's 1 time use, 3. There's no private data displayed back in the application and 4. I may use captcha, but since there's no private data, thats probably overkill.
THanks
© Stack Overflow or respective owner