I want to make a log in script for my website using some special SHA256 encryption and a mysql database linking with it. (And a form ofcourse :P)
I use the Minecraft Plugin "Authme" for the registration. It hashes a password in SHA256 and stores it into a mysql database. But the code $SHA$ce9b7692bd2b8f79$644c2a5710bb93f82471d08234435d7d02b1bbc09aff2cf23370f187aab37716
isn't the same as the SHA256 hashes I made from some websites. 4aae7aba013ffed685a1354a0ebb576b8f1f58997b96cf3ef096282cfe737bff
The developers at Authme gave me a "simple" code to decrypt the password, but I don't know how to fit it within my script.
// @return true if password and nickname match
function check_password_db($nickname,$password) {
// Here u have to include your DB connection and select!
$a=mysql_query("SELECT password FROM authme where username = '$nickname'");
if(mysql_num_rows($a) == 1 ) {
$password_info=mysql_fetch_array($a);
$sha_info = explode("$",$password_info[0]);
} else
return false;
if( $sha_info[1] === "SHA" ) {
$salt = $sha_info[2];
$sha256_password = hash('sha256', $password);
$sha256_password .= $sha_info[2];;
if( strcasecmp(trim($sha_info[3]),hash('sha256', $sha256_password) ) == 0 )
return true;
else return false;
}
}
So the bottom line is: I want to know how to make a form that logs a user in to my website by checking if he entered the right password by looking at the data in mySQL. If you need more info just reply and I'll give you it. My goal is to make a login script that works with sessions.
The tables i have are ID, am_ (username), password and ip.
Can you give me something like a code to do that? (Making a form with username and password, and look whether its valid or not)
Sorry for my typo's, I come from The Netherlands..