<bdo id='vbTQj'></bdo><ul id='vbTQj'></ul>
      1. <small id='vbTQj'></small><noframes id='vbTQj'>

      2. <legend id='vbTQj'><style id='vbTQj'><dir id='vbTQj'><q id='vbTQj'></q></dir></style></legend>
        <tfoot id='vbTQj'></tfoot>

        <i id='vbTQj'><tr id='vbTQj'><dt id='vbTQj'><q id='vbTQj'><span id='vbTQj'><b id='vbTQj'><form id='vbTQj'><ins id='vbTQj'></ins><ul id='vbTQj'></ul><sub id='vbTQj'></sub></form><legend id='vbTQj'></legend><bdo id='vbTQj'><pre id='vbTQj'><center id='vbTQj'></center></pre></bdo></b><th id='vbTQj'></th></span></q></dt></tr></i><div id='vbTQj'><tfoot id='vbTQj'></tfoot><dl id='vbTQj'><fieldset id='vbTQj'></fieldset></dl></div>
      3. 解决 PHP 中不安全的随机数生成问题

        时间:2023-06-22
          <tbody id='43vhg'></tbody>

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

            <bdo id='43vhg'></bdo><ul id='43vhg'></ul>
              <legend id='43vhg'><style id='43vhg'><dir id='43vhg'><q id='43vhg'></q></dir></style></legend>

                  <small id='43vhg'></small><noframes id='43vhg'>

                  <tfoot id='43vhg'></tfoot>
                  本文介绍了解决 PHP 中不安全的随机数生成问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我们在各种 Drupal 模块上运行 Fortify 扫描,一个常见的严重/高结果是不安全的随机性".它指出 rand() 函数无法承受密码攻击.

                  we are running Fortify scans on various Drupal modules, and a common critical/high result is "Insecure Randomness". It states that the rand() function cannot withstand a cryptographic attack.

                  我的问题 - 这是一个严重的问题吗?如何在 PHP 中修复它?

                  My question - is this a serious concern? How to fix it in PHP?

                  谢谢.

                  推荐答案

                  这个问题的答案完全取决于您使用 rand() 调用的结果.

                  The answer to this question entirely depends on what you are using the results from the rand() call for.

                  如果您将它们用于诸如加密密钥之类的事情,其中工具的安全性取决于您的随机数的随机性,那么,是的,这是一个严重的问题.在这种情况下,您不应调用 rand() 或 mt_rand(),因为两者都不会产生足够随机的随机"数字,可以依赖于加密使用.你真的想利用你正在运行的平台的底层伪随机数生成器 (PRNG) - Unix/Linux 系统上的/dev/urandom 或 Windows 系统上的crypto-api - 因为这些已经被广泛研究并产生适用于密码系统的真正随机数.PHP 并没有让访问这些随机源变得那么容易,但是确实存在关于如何这样做的示例(像这样 -> http://www.php.net/manual/en/function.mt-rand.php#83655).

                  If you're using them for things like cryptographic keys, where the security of the tool depends on the randomness of your random numbers, then, yes, this is a serious concern. In that case, you should not call rand() or mt_rand(), as both do not produce "random" numbers that are sufficiently random to rely on for cryptographic use. You really want to make use of the platform you're running on's underlying pseudorandom number generator (PRNG) - /dev/urandom on a Unix/Linux system or the crypto-api on a Windows system - as these have been studied extensively and produce really random numbers that are suitable for use in cryptosystems. PHP doesn't make accessing these random sources all that easy, but examples do exist on how to do so (like this -> http://www.php.net/manual/en/function.mt-rand.php#83655).

                  如果您将随机数用于其他用途,例如随机化哪个选项首先呈现给用户,或者类似的事情,其中生成的数字没有以任何加密方式使用,那么您可能 能够逃脱使用 rand() 或 mt_rand().但是,如果您的应用程序/模块的安全性依赖于良好的随机数,那么您确实需要利用操作系统来源,如上所述.

                  If you're using randoms for something else, like to randomize which option is presented to the user first, or something like that, where the numbers produced are not being used in any cryptographical way, then you may be able to get away with using rand() or mt_rand(). But, if your applications/modules rely on good random numbers for their security, you really need to take advantage of the OS sources, as described above.

                  这篇关于解决 PHP 中不安全的随机数生成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将数组传递给 Drupal 菜单回调 下一篇:Drupal:在网络表单中的提交按钮上方添加免责声明文本

                  相关文章

                  1. <legend id='G1jIp'><style id='G1jIp'><dir id='G1jIp'><q id='G1jIp'></q></dir></style></legend>
                    <tfoot id='G1jIp'></tfoot>
                        <bdo id='G1jIp'></bdo><ul id='G1jIp'></ul>

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

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