Thread: php crypt
View Single Post
Old 11-26-2003, 02:21 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,530
sde is on a distinguished road
i usually use md5() for encrypting. and the logic will work for crypt as well.

your not going to decrypt at all, but rather encrypt the password they enter, and compare it to the encrypted password stored in the database.

when you use md5() , it produces a 32 character string, and that is the string you would store in the database.
PHP Code:
<?
// lets say you had a form that passed username and password
$encrypted_password md5($_POST['password']);

$result=mysql_query("select * from users 
             where username='" 
$_POST['username'] . "' 
               and password='" 
$encrypted_password "'");

// if any rows were found then it was successful
?>
__________________
Mike
sde is offline   Reply With Quote