0

对于我们的项目,我们正在尝试使用 salt 命令加密密码,但它似乎不起作用。这是我们目前所拥有的:

<html>
<?php
$con=msqli_connect('XXXX', '<username>', '<password>', 'XXXXXXX');
// Create connection
// Check connection
if (mysqli_connect_erno($con));
{
    echo "Failed to connect to Mysql: " . msqli_connect_error();
}
?>  

<?php
$Password = $_POST['password'];

$salt = //


$password = sha1(userPasswordinput . salt);
?>
<head>

<title>Password Ecryption</title>
</head>

<body>


</body>
</html>

与 mysql 的连接正常,但显然有问题。密码变量是从另一个代码页发布的,该部分也可以正常工作。

4

1 回答 1

1

您的代码中有一些错误导致 salt 和张贴的密码无法正常工作。试试下面的代码:

<?php
// lower case variable names for non-objects (developer preference)
$password_input = $_POST['password'];

// you had a syntax error here (missing variable value and ending semi-colon)
$salt = 'SomePasswordSaltString';

// you had another syntax error here (incorrect variable reference and missing $)
$password = sha1($password_input . $salt);
?>
于 2013-05-08T22:06:03.040 回答