mysql - PHP login script using SHA256 -
i want make log in script website using special sha256 encryption , mysql database linking it. (and form ofcourse :p)
i use minecraft plugin "authme" registration. hashes password in sha256 , stores mysql database. code $sha$ce9b7692bd2b8f79$644c2a5710bb93f82471d08234435d7d02b1bbc09aff2cf23370f187aab37716 isn't same sha256 hashes made websites. 4aae7aba013ffed685a1354a0ebb576b8f1f58997b96cf3ef096282cfe737bff
the developers @ authme gave me "simple" code decrypt password, don't know how fit within script.
// @return true if password , nickname match function check_password_db($nickname,$password) { // here u have include db connection , select! $a=mysql_query("select password authme 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 bottom line is: want know how make form logs user in website checking if entered right password looking @ data in mysql. if need more info reply , i'll give it. goal make login script works sessions.
the tables have id, am_ (username), password , ip.
can give me code that? (making form username , password, , whether valid or not)
sorry typo's, come netherlands..
well, understand: use library registration, , want make login form uses same authorization mechanism used registration.
in case posted code should used checking password yourself. pass user input , make sure select statement uses correct table , columns.
as why hashes differ, it's because user input isn't encrypted sha256(password) sha256(concat(sha256(password),salt)) concat string concatenation operation , salt additional input, in case equal part between $ characters (in example: ce9b7692bd2b8f79).
additionaly, cannot "decrypt" hashed data. can hash other data , compare both hashes check if same. if same, both inputs (probably) same. (the "probably" part because hashing functions surjections, not bijections.)
Comments
Post a Comment