MySQL fill column with random hashes
Posted: Thu Dec 03, 2009 3:33 am
Hi everyone
I have a table of 30,000 records and I'd like to generate a random md5 (or whatever) hash for each one.
I could use PHP to go through and generate all these then update the database.
Just wondering if there's a way to do it within a MySQL query which would probably be a bit quicker.
I understand md5 and sha-1 are no longer considered secure for cryptographic purposes but I think they'll be good enough for our simple needs.
I'd also like to store this as a hex value rather than binary.
I realise I could use the MySQL MD5() function, but what's the best way to get a strong random in MySQL to pass to the MD5() function?
Can MySQL be persuaded to use /dev/urandom to get a strong random?
Cheers, B
I have a table of 30,000 records and I'd like to generate a random md5 (or whatever) hash for each one.
I could use PHP to go through and generate all these then update the database.
Just wondering if there's a way to do it within a MySQL query which would probably be a bit quicker.
I understand md5 and sha-1 are no longer considered secure for cryptographic purposes but I think they'll be good enough for our simple needs.
I'd also like to store this as a hex value rather than binary.
I realise I could use the MySQL MD5() function, but what's the best way to get a strong random in MySQL to pass to the MD5() function?
Can MySQL be persuaded to use /dev/urandom to get a strong random?
Cheers, B