TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Which method/algorithm do you use to securely hash password in PHP?

2 pointsby startupflixabout 7 years ago

2 comments

thaumaturgyabout 7 years ago
Since PHP 5.5, the answer has been:<p><pre><code> $hash = password_hash($password, PASSWORD_BCRYPT) </code></pre> and<p><pre><code> password_verify($password, $hash) </code></pre> These are a part of the PHP standard library and should be available in any PHP installation &gt;= 5.5: <a href="https:&#x2F;&#x2F;secure.php.net&#x2F;manual&#x2F;en&#x2F;function.password-hash.php" rel="nofollow">https:&#x2F;&#x2F;secure.php.net&#x2F;manual&#x2F;en&#x2F;function.password-hash.php</a><p>If you&#x27;re stuck with an older version of PHP, you should try to upgrade it. If you really really can&#x27;t, the answer gets more complicated, but you can still store and compare a bcrypt&#x27;d hash.
评论 #16984207 未加载
bufferoverflowabout 7 years ago
Bcrypt &#x2F; SHA256 &#x2F; SHA512 &#x2F; Scrypt are all fine.<p>Don&#x27;t forget to salt.
评论 #16985859 未加载