Passwords
|
|
|
|
<? function EncryptedPassword($pass) {
$passwordkey = 'super.long.secret.password.key.that.will.take.forever.to.brute.force.the.md5.hash.so.anyone.trying.should.just.give.up-';
return md5(base64_encode($passwordkey.$pass));
} ?>
|
|
|
Usage Example
|
//$_POST['password'] is the variable when registering.
$password=EncryptedPassword($_POST['password']);
//When registering
query "INSERT into table SET `password`='$password' ...etc";
When logging in, say $_POST['login_pass'] is the submitted pass. and $databasepassword is the encrypted PW stored in DB
if(EncryptedPassword($_POST['login_pass'] != $databasepassword) {
echo "Failed to login";
}else{
echo "Welcome!";
}
//Change key to some super long phrase, but DO NOT CHANGE IT once youve registered an account with it, if you change the key, any accounts made with old key will not work.
|
|
|
Rate This Script
|
|
|
|