为此,我使用了md5()。
// username and password sent from form
$username=$_POST['myusername'];
$password=$_POST['mypassword'];
$encrypted_password=md5($password);
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$encrypted_password'";
$result=mysql_query($sql);但我听说这不安全。我是初学者,所以请给我一个好的密码加密方法?另外,如果截取了帖子数据,它是否会以明文形式出现?
发布于 2014-01-18 16:50:29
我是初学者,所以请给我一个好的密码加密方法。
利用crypt()代替md5()
<?php
$hashed_password = crypt('mypassword'); // let the salt be automatically generated
if (crypt($user_input, $hashed_password) == $hashed_password) {
echo "Password verified!";
}
?>PHP Manual中的一些示例
另外,如果截取了帖子数据,它是否会以明文形式出现?
当然啦!如果您真的很关心这个问题,请在您的域中配置一个SSL证书。
发布于 2014-01-18 16:51:30
在PHP5.5中,您可以使用新的password_hash
$hash = password_hash($password, PASSWORD_DEFAULT);在旧版本中,有一个兼容层,它也是这样做的:compat
https://stackoverflow.com/questions/21206940
复制相似问题