简体   繁体   English

这是否足够安全,用于散列

[英]Is this secure enough, for hashing

hash('sha512', $_POST['password'] . time()) 

我听说过很多关于这个和那个的事情,并且无法得出结论......

我建议在创建和散列密码时添加一个 ,除此之外 - 是的。

You're using time() as a salt . 你用time()作为 You can do that, but don't forget to store it (otherwise, how would you ever be able to check that the given password concatenated with the salt matches the stored hash?). 您可以这样做,但不要忘记存储它(否则,您将如何检查与盐连接的给定密码是否与存储的哈希相匹配?)。 sha512 is a great choice for a hash algorithm. sha512是哈希算法的绝佳选择。 I'd suggest 我建议

$salt = uniqid('carlgcoder_') . microtime(true);
$hash = hash('sha512', $salt . $_POST['password']);

Use salt. 用盐。 Sample: 样品:

<?php
    $passwordWasSavedInDB = md5($_POST['password']."_paranoia_")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM