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

      <i id='AaZ27'><tr id='AaZ27'><dt id='AaZ27'><q id='AaZ27'><span id='AaZ27'><b id='AaZ27'><form id='AaZ27'><ins id='AaZ27'></ins><ul id='AaZ27'></ul><sub id='AaZ27'></sub></form><legend id='AaZ27'></legend><bdo id='AaZ27'><pre id='AaZ27'><center id='AaZ27'></center></pre></bdo></b><th id='AaZ27'></th></span></q></dt></tr></i><div id='AaZ27'><tfoot id='AaZ27'></tfoot><dl id='AaZ27'><fieldset id='AaZ27'></fieldset></dl></div>
      • <bdo id='AaZ27'></bdo><ul id='AaZ27'></ul>
      <tfoot id='AaZ27'></tfoot>
    1. <legend id='AaZ27'><style id='AaZ27'><dir id='AaZ27'><q id='AaZ27'></q></dir></style></legend>
    2. password_hash 每次返回不同的值

      时间:2023-10-03

            <bdo id='1c5wB'></bdo><ul id='1c5wB'></ul>
            <legend id='1c5wB'><style id='1c5wB'><dir id='1c5wB'><q id='1c5wB'></q></dir></style></legend>

          • <small id='1c5wB'></small><noframes id='1c5wB'>

              <tbody id='1c5wB'></tbody>

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

                本文介绍了password_hash 每次返回不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在制作一个登录系统,我想对密码进行散列以使其更安全,但它每次都返回不同的散列,甚至无法使用 password_verify() 进行验证,这是我的代码:

                I'm making a login system, and I want to hash the passwords to make them more secure, but it returns a different hash every time, and can't even be verified using password_verify(), here is my code:

                $password = password_hash($password4, PASSWORD_DEFAULT);
                

                这是我的验证代码:

                if(password_verify($password4, $dbpassword))
                

                推荐答案

                所以让我们一次一个部分

                So let's take it one part at a time

                但它每次都返回不同的哈希

                but it returns a different hash every time

                就是这个想法.password_hash 旨在每次生成随机盐.这意味着您必须单独分解每个散列,而不是猜测用于所有内容的一种盐并获得巨大优势.

                That's the idea. password_hash is designed to generate a random salt every time. This means you have to break each hash individually instead of guessing one salt used for everything and having a huge leg up.

                无需MD5 或进行任何其他散列.如果你想提高 password_hash 的安全性,你可以通过更高的成本(默认成本是 10)

                There's no need to MD5 or do any other hashing. If you want to raise the security of password_hash you pass a higher cost (default cost is 10)

                $password = password_hash($password4, PASSWORD_DEFAULT, ['cost' => 15]);
                

                至于验证

                if(password_verify($password4, $dbpassword))
                

                所以 $password4 应该是你未散列的密码,$dbpassword 应该是你存储在数据库中的哈希

                So $password4 should be your unhashed password and $dbpassword should be the hash you've stored in your database

                这篇关于password_hash 每次返回不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PHP 短哈希,如 URL 缩短网站 下一篇:为什么 crypt/blowfish 使用两种不同的盐生成相同的

                相关文章

                最新文章

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

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