alienmojo Posted February 2, 2007 Share Posted February 2, 2007 ok im finally adding sha1 into my website what i cant figure out how to do is get the password already stored in the database hashed into the sha1 format Link to comment https://forums.phpfreaks.com/topic/36733-hashing/ Share on other sites More sharing options...
fert Posted February 2, 2007 Share Posted February 2, 2007 Just get the passwords from the database re-hash them and then update the fields Link to comment https://forums.phpfreaks.com/topic/36733-hashing/#findComment-175185 Share on other sites More sharing options...
Cagecrawler Posted February 2, 2007 Share Posted February 2, 2007 If you have phpMyAdmin, you can do it manually by editing the row you want and selecting sha1 from the function dropdown menu. If you want to do it through php, then this script will update all current passwords to sha1: <?php //Connect code $query=mysql_query("SELECT * FROM users"); while($user=mysql_fetch_array($query)) { $id=$user['id']; $password=sha1($user['password']); mysql_query("UPDATE users SET password='$password' WHERE id='$id' LIMIT 1"); } ?> Warning: Only run once, because running more than once will sha1 the sha1'd passwords, totally mucking up the data. Link to comment https://forums.phpfreaks.com/topic/36733-hashing/#findComment-175186 Share on other sites More sharing options...
The Little Guy Posted February 2, 2007 Share Posted February 2, 2007 When the user logins in, you need to match hashed values, so you will need to convert what they type in to sha1, then compare the two. -- Just a little F.Y.I. Link to comment https://forums.phpfreaks.com/topic/36733-hashing/#findComment-175217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.