23.02.2018, 07:41
Hello Guys i am using SHA256_PassHash to hash the password if a player registers on the server..
i am also working on UCP but there's a problem in Checking the hashed password plzz help me fixing it here's the code below.i am having problem in De-Hashing The Password On The Website For UCP
i am also working on UCP but there's a problem in Checking the hashed password plzz help me fixing it here's the code below.i am having problem in De-Hashing The Password On The Website For UCP
Код:
<?php
session_start();
include 'dbh.inc.php';
if(isset($_POST['name'], $_POST['password'])) {
$name = $_POST['name'];
$password = $_POST['password'];
$sql = "SELECT * FROM users WHERE Name='$name'";
$result = $conn->query($sql);
if (empty($name && $password)) {
header("Location: ../page1.php?invalid=empty");
exit();
} else {
if($result->num_rows < 1) {
header("Location: ../page1.php?invalid=login");
exit();
} else {
$row = mysqli_fetch_assoc($result);
//De-hashing the password
$salt = "786t!t>D<QW*@!)#$>C)_Agdh";
$hash1 = hash('sha256', $password . $salt);
$hash = strtoupper($hash1);
if ($row['Password'] == $hash) {
header("Location: ../page1.php?login=success");
$_SESSION['user-name']= $name;
$_SESSION['user-password']=$password;
exit();
} else {
header("Location: ../page1.php?invalid=login");
exit();
}
}
}
}
?>


