|
Log in Script
Encrypting Passwords with mcrpyt
1 way encryption with crypt()
When a user registers for our site, they will enter a password via $_POST . We will use the crypt() function to encrypt this password and then store the encrypted version in our database. Whenever the user tries to log in, we will ask them to type in their username and password and we will again use crypt() to encrypt their password and see if the encrypted form of what they typed in maches the encrypted password in our database. If so, we will let them log in! Note there are many well known and powerful encryption algorithms. You could also use sha1(), md5() or a varitey of other functions.
<?php
$password = "abcdefg"; echo crypt($password);
?>
- If you use crypt("abcdefg") you will get : $1$Af33L3Sf$T9bX0u4iBxv401RpxajuJ0
- If you use md5("abcdefg") you will get : 7ac66c0f148de9519b8bd264312c4d64
- If you use sha1("abcdefg") you will get : 2fb5e13419fc89246865e7a324f476ec624e8740
Top
|