Jump to content

[SOLVED] MD5


andrewgarn

Recommended Posts

I have as table of users with passwords saved as varchar unencrypted. Obviously this isnt a good idea if the database were to get compromised. So I looked at mysql encryption, which can be done using php md5

 

What i'd like to do is create a temporary php page which will turn the passwords into md5 in the database.

 

Not totally sure how to do this, I presume it would be something like:

 

<?php
$sql = mysql_query("SELECT password from user");
while($row = mysql_fetch_array($sql))
{
       $username = $row["username"];
       $password = $row["password"];
       $password = md5($password);
       //insert back into database

}

Then i would need to add something to the register and login commands right?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/113453-solved-md5/
Share on other sites

MD5 is not encryption, it's a hash. One way. Once you hash it, you can't get the information back without extensive rainbow tables (which is a subject for different day).

 

It's common to hash the password when the user registers/changes password and store the hash in the db then when they go to logon, hash the password they enter and compare.

Link to comment
https://forums.phpfreaks.com/topic/113453-solved-md5/#findComment-582950
Share on other sites

I didnt wish to do it unless I thought it would work as i'm editing real user data. Which if I break have to reset all the password data manually.

 

And a couple of posts above was a typo sorry, I meant password not username

 

Anyway I've done it now. Seems to work fine. Thanks to all that posted

 

 

Link to comment
https://forums.phpfreaks.com/topic/113453-solved-md5/#findComment-582968
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.