我正在尝试为我的网站制作一个或多或少安全的登录系统,我没有太多时间来保护东西,所以我边走边学。想听听一些关于以下哪个更好以及为什么的观点。(或者我在某个地方犯了错误?)
$staticsalt = '$%*#)$*)^A#$#543667ggfdf\#$%x';
$random = md5(uniqid(mt_rand(), true));
$salt = hash('sha512',$random.$_POST['password'].microtime().$staticsalt);
或者(不需要在数据库中使用 $salt ......)
$password = crypt($_POST['password'], '$2a$12$'.$salt);
或(我也需要数据库中的 $salt ......)
$password = hash('sha512',$salt.$_POST['password']);