crypt is a one way algorithm very much like md5 but utilizes STANDARD DES, EXTENDED DES, MD5, AND BLOWFISH with a salt and no public/private key pairs.
If you want two way encryption schemes, you must either create your own (can be quite tedious), or you can use mcrypt_xxx(). mcrypt_xxx() support has to be configured for PHP. You can check to see if you have it by using phpinfo();
If you do have mcrypt, you can do this to see what your algorithm names are:
Yep. If you are using encryption for password, you won't need to decrypt them.
There are a number of ways you can do this, but here is one scenario:
Login:
username: chad
password: mypass
Verification:
$private_key = "fsdafdsafjdksalfjdsa";
$q = "SELECT COUNT(*) as found FROM users WHERE username='$username' AND password=ENCRYPT($password,$private_key)";
$r = mysql_query($q);
$c = mysql_fetch_array($r);
if($c["found"] > 0) {
......and stuff here for success
}
else {
......and stuff here for failure.
}
basically, MySQL's ENCRYPT(STR,SALT); uses UNIX crypt(). When a user registers, we insert the user information into the table using the same ENCRYPT() function for the password (making sure to use the same salt as well). Now we just have to see if the username and encrypted passwords match.
Really, you should only use bi-directional encryption if you require the passing of data to and from different sources where the other source has to be able to decrypt the data to read it.
md5 and the other algorithms used by crypt (which MySQL's ENCRYPT() function uses), have been proven to be 99.99% hack free as long as you use a good salt.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.