<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 中不安全的随机数生成问题

        Address insecure random number generation in PHP(解决 PHP 中不安全的随机数生成问题)
          <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 中不安全的随机数生成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  1. <legend id='G1jIp'><style id='G1jIp'><dir id='G1jIp'><q id='G1jIp'></q></dir></style></legend>
                    <tfoot id='G1jIp'></tfoot>
                        <tbody id='G1jIp'></tbody>
                        <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>