wildteen88 Posted May 11, 2008 Share Posted May 11, 2008 Wouldn't it be easier to just run the query: UPDATE `members` SET `password`=md5(`password`) Again, as wildteen has emphasized, make sure you back up your data and run this query only once. I wasn't sure whether to use that query as I thought Mysql will set all passwords to the md5 hash of the string '`password`' (minus the quotes) and not the value of the password field. However after testing this my thoughts where wrong. I found out why my code wasn't working correctly though. The following line: while(list($username, $password) = mysql_fetch_row(mysql_query('SELECT username, password FROM members'))) actually causes an infinity loop Link to comment https://forums.phpfreaks.com/topic/105165-md5/page/2/#findComment-538539 Share on other sites More sharing options...
eaglelegend Posted May 11, 2008 Author Share Posted May 11, 2008 ok... errm I pasted gingers code into thre query and it says You have to choose at least one column to display what coloumn? Link to comment https://forums.phpfreaks.com/topic/105165-md5/page/2/#findComment-538541 Share on other sites More sharing options...
wildteen88 Posted May 11, 2008 Share Posted May 11, 2008 ok... errm I pasted gingers code into thre query and it says You have to choose at least one column to display what coloumn? With GingerRobots suggestion <?php include 'header.php'; mysql_query('UPDATE `members` SET `password`=md5(`password`)'); echo 'Passwords reset. DELETE THIS SCRIPT NOW DONOT RERUN.'; ?> Link to comment https://forums.phpfreaks.com/topic/105165-md5/page/2/#findComment-538544 Share on other sites More sharing options...
maxudaskin Posted May 11, 2008 Share Posted May 11, 2008 What I'd do is this: <?php $password = "password"; $password = md5($password); // 319f4d26e3c536b5dd871bb2c52e3178 $password = substr($password,0,16); // 319f4d26e3c536b5 // For extra security, do it again $password = md5($password); // ce90da7acc4c917baa12b361b4d1a126 $password = substr($password,0,16); // ce90da7acc4c917b ?> Link to comment https://forums.phpfreaks.com/topic/105165-md5/page/2/#findComment-538548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.