Reputation: 289
As of now I have this line of code
<?php
$pass = "12312312";
echo md5(crypt($pass))
?>
I know crypt can randomly generate salt but I don't have any idea how can I compare it on the user input.
What are the fields do I need for my log in table? and also, what data will I insert to my table?
thanks!
Upvotes: 1
Views: 179
Reputation: 1590
You can store password in table as below
$pass = "12312312";
// store this in table with separate column
$salt = md5("any variable"); // may be email or username
// generate password
$password = sha1($salt.$pass);
// now store salt and password in table
And you can check password like
$pass = "User input";
// get the user from database based on user id or username
// and test the password stored in db with
if($passwordFromTable == sha1($saltFromTable.$pass))
{
// correct
}
Upvotes: 5