First off sha1, turns any words no matter how long into a 32 character key. Ok so you would set a basic sha1 statment like this:
<?PHP $encrypt = secure; $action = sha1($encrypt); ?>That code will turn the variable encrypt into a 32 char key. Ok well lets get a little trickier using this in an SQL query.
<?PHP // .... code above this cut $password = $_POST['password']; $encrypt = sha1($password); $query = mysql_query("INSERT INTO `db` VALUES ('$encrypt'); // Remember that the query will change, and so may the variables ?>Ok well after you set that in great...now how do you get the info out? well um... Idk
haha ok well the script to gain information is obvious, but yet some might look past it because of that
<?PHP $password = $_POST['password']; $encrypt = sha1($password); $query = mysql_query("SELECT * FROM `db` WHERE `password` = '$encrypt'"); ?>yup thats it... basicly thats all there really is to know about sha1(); its a great encrypter and not widely used so its harder to crack, however if you are stubborn and want to use md5, substitute the sha1() function for the md5() function, thats all there is to it .
Ok well if anyone was able to follow that, I hope you learned something...this was my first tutorial so I hope you can gain some knowledge off of it.
Edited by liveman, 24 December 2005 - 03:00 PM.