[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/ramsey/uuid/src/Generator/ -> MtRandGenerator.php (source)

   1  <?php
   2  /**
   3   * This file is part of the ramsey/uuid library
   4   *
   5   * For the full copyright and license information, please view the LICENSE
   6   * file that was distributed with this source code.
   7   *
   8   * @copyright Copyright (c) Ben Ramsey <[email protected]>
   9   * @license http://opensource.org/licenses/MIT MIT
  10   * @link https://benramsey.com/projects/ramsey-uuid/ Documentation
  11   * @link https://packagist.org/packages/ramsey/uuid Packagist
  12   * @link https://github.com/ramsey/uuid GitHub
  13   */
  14  
  15  namespace Ramsey\Uuid\Generator;
  16  
  17  /**
  18   * MtRandRandomGenerator provides functionality to generate strings of random
  19   * binary data using the `mt_rand()` PHP function
  20   *
  21   * @deprecated The mt_rand() function is not a reliable source of randomness.
  22   *     The default RandomBytesGenerator, which uses the random_bytes() function,
  23   *     is recommended as the safest and most reliable source of randomness.
  24   *     <em>This generator will be removed in ramsey/uuid 4.0.0.</em>
  25   * @link http://php.net/mt_rand
  26   */
  27  class MtRandGenerator implements RandomGeneratorInterface
  28  {
  29      /**
  30       * Generates a string of random binary data of the specified length
  31       *
  32       * @param integer $length The number of bytes of random binary data to generate
  33       * @return string A binary string
  34       */
  35      public function generate($length)
  36      {
  37          $bytes = '';
  38  
  39          for ($i = 1; $i <= $length; $i++) {
  40              $bytes = chr(mt_rand(0, 255)) . $bytes;
  41          }
  42  
  43          return $bytes;
  44      }
  45  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer