encrypting passwords, how to decrypt?

From: Date: Thu, 17 Jan 2002 20:54:06 +0000
Subject: encrypting passwords, how to decrypt?
Groups: php.general 
Request: Send a blank email to php-general+get-80973@lists.php.net to get a copy of this message
Ok, even if I don't need encryption I thought I might go ahead and try to learn it, and as I said in the previous post I managed to get it working everywhere but on the login script first I have a form that sends username and password to login.php, in that file I have something like this <? $the host user pswd and db vars mysql_connect($host, $user, $pswd); mysql_select_db($db); $query = "SELECT * FROM users WHERE username='$username' and password='$password'"; $result = mysql_query($query); $num = mysql_num_rows($result); if ( $num != NULL ) { session_start(); session_register(admin_allow); $admin_allow = "mytopsecretpassword"; header("location: admin/index.php"); } else { header("location: admin.php"); } ?> I know it looks messy, and I removed some stuff to make it smaller to post, but when I use non encrypted passwords this works fine, my problem is that I don't know how to to do read a encrypted password in the $query, or if I need to do it in some other way(been trying a few different this far) I tried with $query = "SELECT * FROM users WHERE username='$username' and password=password('$password')"; but that made $num = 0, and the login fail I'm getting really tired (from sleeping to little..) and that might have reduced my thinking even more than usual, but what am I doing wrong ? :P Hawk

« previous php.general (#80973) next »