• <tfoot id='ufbNr'></tfoot>
  • <i id='ufbNr'><tr id='ufbNr'><dt id='ufbNr'><q id='ufbNr'><span id='ufbNr'><b id='ufbNr'><form id='ufbNr'><ins id='ufbNr'></ins><ul id='ufbNr'></ul><sub id='ufbNr'></sub></form><legend id='ufbNr'></legend><bdo id='ufbNr'><pre id='ufbNr'><center id='ufbNr'></center></pre></bdo></b><th id='ufbNr'></th></span></q></dt></tr></i><div id='ufbNr'><tfoot id='ufbNr'></tfoot><dl id='ufbNr'><fieldset id='ufbNr'></fieldset></dl></div>

      <legend id='ufbNr'><style id='ufbNr'><dir id='ufbNr'><q id='ufbNr'></q></dir></style></legend>

        <small id='ufbNr'></small><noframes id='ufbNr'>

          <bdo id='ufbNr'></bdo><ul id='ufbNr'></ul>

        什么是 password_hash() 的替代方案(PHP 5 <5.5.0)?

        时间:2023-10-03

                <bdo id='CGbzO'></bdo><ul id='CGbzO'></ul>

                <small id='CGbzO'></small><noframes id='CGbzO'>

                1. <legend id='CGbzO'><style id='CGbzO'><dir id='CGbzO'><q id='CGbzO'></q></dir></style></legend>

                2. <i id='CGbzO'><tr id='CGbzO'><dt id='CGbzO'><q id='CGbzO'><span id='CGbzO'><b id='CGbzO'><form id='CGbzO'><ins id='CGbzO'></ins><ul id='CGbzO'></ul><sub id='CGbzO'></sub></form><legend id='CGbzO'></legend><bdo id='CGbzO'><pre id='CGbzO'><center id='CGbzO'></center></pre></bdo></b><th id='CGbzO'></th></span></q></dt></tr></i><div id='CGbzO'><tfoot id='CGbzO'></tfoot><dl id='CGbzO'><fieldset id='CGbzO'></fieldset></dl></div>
                    <tbody id='CGbzO'></tbody>
                  <tfoot id='CGbzO'></tfoot>
                3. 本文介绍了什么是 password_hash() 的替代方案(PHP 5 <5.5.0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  根据手册:password_hash 这个函数可以用于(PHP 5 >= 5.5.0)

                  According to manual: password_hash this function can be used for (PHP 5 >= 5.5.0)

                  在寻找替代方法后,我从这里找到了这个简单的函数:http://www.sitepoint.com/password-hashing-in-php/

                  After searching for an alternative way I found this simple function from here: http://www.sitepoint.com/password-hashing-in-php/

                  function generateHash($password) {
                      if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) {
                          $salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22);
                          return crypt($password, $salt);
                      }
                  }
                  

                  我可以在使用前通过使用 function_exists 来管理我的代码,但我的问题是关于上述替代代码是否安全,或者在旧版本的 PHP 中是否有其他替代代码?

                  I can manage my code by using function_exists before using, but My question is about above alternative code if its secure or not, or is there any alternative in older versions of PHP?

                  推荐答案

                  对于 PHP 版本

                  5.3.7,我推荐:

                  For PHP versions < 5.3.7, I'd recommend:

                  http://www.openwall.com/phpass/

                  对于 PHP 版本 >= 5.3.7,使用:

                  For PHP versions >= 5.3.7, use:

                  https://github.com/ircmaxell/password_compat

                  生成自己的盐需要很多知识,因为好的、合适的盐需要大量的熵.在 PHP 中生成这个 salt 很麻烦,这就是为什么你通常最终依赖其他资源为你提供这个字符串,例如 /dev/urandomopenssl_random_pseudo_bytes.相信我,如果没有认真的研究和考虑,这不是你想自己尝试的事情.

                  Generating your own salts takes a lot of know how, because a good, proper salt requires a lot of entropy. Generating this salt in PHP is troublesome, which is why you usually end up depending on other resources to provide this string for you, such as /dev/urandom or openssl_random_pseudo_bytes. Believe me, this isn't something you want to try yourself without serious research and consideration.

                  建议使用新的 password_* API,但如果您需要支持旧版本的 PHP,这可能会出现问题,这就是 PHPass 的用武之地.必须讨厌那些每月 1 美元的托管计划PHP 5.2

                  Using the new password_* API is recommended, but it can be problematic if you need to support older versions of PHP, which is where PHPass comes in. Gotta hate those $1 per month hosting plans with PHP 5.2

                  这篇关于什么是 password_hash() 的替代方案(PHP 5 <5.5.0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP SHA3 功能 下一篇:使用文件的一部分生成 JavaScript 文件哈希值

                  相关文章

                  最新文章

                  <small id='o4KiK'></small><noframes id='o4KiK'>

                    1. <i id='o4KiK'><tr id='o4KiK'><dt id='o4KiK'><q id='o4KiK'><span id='o4KiK'><b id='o4KiK'><form id='o4KiK'><ins id='o4KiK'></ins><ul id='o4KiK'></ul><sub id='o4KiK'></sub></form><legend id='o4KiK'></legend><bdo id='o4KiK'><pre id='o4KiK'><center id='o4KiK'></center></pre></bdo></b><th id='o4KiK'></th></span></q></dt></tr></i><div id='o4KiK'><tfoot id='o4KiK'></tfoot><dl id='o4KiK'><fieldset id='o4KiK'></fieldset></dl></div>
                      <tfoot id='o4KiK'></tfoot>
                      • <bdo id='o4KiK'></bdo><ul id='o4KiK'></ul>
                      <legend id='o4KiK'><style id='o4KiK'><dir id='o4KiK'><q id='o4KiK'></q></dir></style></legend>