posted 03/8/2008 by Chris

Encrypting a password using the md5 algorithm is so easy that you really have no excuse not to use it for saving passwords into your database...

 

$password = 'x9Fe2f4f';

//this is all you have to do to create a 32-character encrypted hash

$encrypted_password = md5($password);

//check a user's password that they input with the encrypted one

if( md5($users_password) == $encrypted_password )

 

See, you're just plain lazy if you can't handle that.

As an aside, here's some useful code to create a random 8- character password...

 

$chars = "abcdefghijkmnopqrstuvwxyz023456789";

srand((double)microtime()*1000000);

$i = 0;

$pass = '' ;

while ($i <= 7) {

$num = rand() % 33;

$tmp = substr($chars, $num, 1);

$pass = $pass . $tmp;

$i++;

}

echo $pass;

 

Share:
facebook myspace digg del.icio.us fark stumbleupon live spurl furl reddit yahoo

COMMENTS (displaying 0 comments)

POST (leave a comment)

Name:
Email:
Message:
Verify:
CAPTCHA Image