n8w Posted December 25, 2008 Share Posted December 25, 2008 What is the best way to convert a non-encrypted column in a database? to and encrypted column using md5? Thanks! Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 select go through the loop, md5 string u want inside the loop then update Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 25, 2008 Share Posted December 25, 2008 There is no need to loop or write any code in order to update all the columns in a table. A single UPDATE query, that can be executed through your favorite database management utility, with no WHERE clause will update all the rows in the table to set the (new or existing) column to any value you want. Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 I assume he has initial values that needed to be encrypted.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 25, 2008 Share Posted December 25, 2008 UPDATE your_table SET your_existing_or_new_column_name = md5(your_existing_column_name) Edit: And since you should be SALTING your value to help prevent database lookups of common md5 values - UPDATE your_table SET your_existing_or_new_column_name = md5(CONCAT(your_existing_column_name,'some random string that you will use when you test values as well')) Quote Link to comment Share on other sites More sharing options...
n8w Posted December 25, 2008 Author Share Posted December 25, 2008 wow .. that is awesome .. thanks! Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 brilliant! thanks for the info PFMaBiSmAd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.