Re: password in md5 to connect to mysql instead of clear password
| From: | Unknown W. Brackets | Date: | Fri, 25 Feb 2005 00:01:58 +0000 |
| Subject: | Re: password in md5 to connect to mysql instead of clear password | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38660@lists.php.net to get a copy of this message | ||
Gael Lams,
The problem is, MD5 is non-reversible. Any encryption you use that is non reversible... obviously cannot be reversed, right? If it can't be reversed, that's what you have to send for the connection - and anyone sending that will get through just fine.
Here, let me explain. If you were to store the password MD5'd, say in $password, you would have to pass that (the md5'd version) to mysql_connect(). If you can pass it to that function, anyone can... and so the encryption doesn't help anyone (except that the password is longer.)
Generally, the solution would be a challenge login, but even then the client needs to know the clear text password, and so it needs to be saved somewhere.
There is one solution to this: certificates, but that's still by machine. See the documentatation for more information:
http://www.php.net/ref.mysql
-[Unknown]
-------- Original Message --------
Hi all I use the classic following rows to connect to a mysql database. I always put $passsword in clear in the php connection file and I wonder whether there is a way to have it in md5 so that someone reading the file could not use it to connect to the db. I googled a bit but find only threads explaining how to have password saved in md5 inside a mysql table which is not I would like to do Regards, Gaëlfunction SQLConnect() { $server_name = 'localhost'; $db_name = 'cmsdb'; $user_name = 'user'; $password = 'clearpassword';if (!$dbconnect =mysql_connect($server_name, $user_name, $password)){ echo "Connection failed to thehost 'localhost'.";exit; } if (!mysql_select_db($db_name)) { echo "Cannot connect todatabase '.$db_name.'";exit; } }