View Single Post
Old 09-10-2007, 07:03 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

ok

you can do this in a number of ways.

i use md5() which is a standard algorithm and used widely. It will return a 32 char hash of anything you process with it from a 5 char password to a whole 30 page text file.

try it...

PHP Code:
$string "dreamweaverclub"//<<< try anything you want in here and at any length
 
echo md5($string); 
ok

when setting up users you need to wrap your $password var in this function

PHP Code:
$password md5($password); 
you need to do this before you insert into the db and make sure you have your password field length set to 32 varchars.

you need to also compare md5 when logging in...

PHP Code:
$password md5($_POST['password']);
 
if (
$password == $row['password']){
//let me in

you cant decrypt an md5 string but you dont need to.
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote