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! Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/ 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 Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723545 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. Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723558 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.. Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723560 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')) Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723562 Share on other sites More sharing options...
n8w Posted December 25, 2008 Author Share Posted December 25, 2008 wow .. that is awesome .. thanks! Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723563 Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 brilliant! thanks for the info PFMaBiSmAd Link to comment https://forums.phpfreaks.com/topic/138377-convert-an-existing-column-to-md5/#findComment-723565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.