Как сменить ХЭШ с MD5 на SHA256 авторизации?
auth.php:
if(empty($_COOKIE["pass"]) || $_COOKIE["pass"]==""){
header("Location: login.php");
}
else{
$per = explode(":", $_COOKIE["pass"]);
$pass_md5 = $per[0];
$login = $per[1];
$search = mysql_query("SELECT * From ".$account['table']." WHERE ".$account['name']."='$login'");
$user = mysql_fetch_array($search);
if($pass_md5 != md5(md5($user["".$account['pass'].""]))){
setcookie("pass", "", 0, "/");
header("Location: login.php");
}
}
//?>
authorization.php:
if(isset($_POST['login']))
{
$name = $_POST['nick'];
$password = $_POST['password'];
$search = mysql_query("SELECT * FROM `".$account['table']."` WHERE `".$account['name']."`='$name'");
if(mysql_num_rows($search)!=0)
{
$user = mysql_fetch_array($search);
if($user["".$account['pass'].""]==$password)
{
setcookie("pass", md5(md5($password)).":".$name, time() + 60*100, "/");
header("Location: ./");
}
else
{
//$info_pass="<div class=\"alert alert-danger\">
//<strong>Ошибка!</strong> Пароль не правильный.
//</div>";
$info_pass="<div class=\"alert alert-danger\">
<strong>Ошибка!</strong> Пароль не правильный.
</div>";
}
}
else
{
$info_user = "<div class=\"alert alert-danger\">
<strong>Ошибка!</strong> Игрок не найден.
</div>";
}
}
if($_GET["access"]=="exit"){
setcookie("pass", "", "0", "/");
header("Location: ./login.php");
}
?>