Debian Codegraph @

vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php

raw
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 * OpenSslRandomGenerator provides functionality to generate strings of random
19 * binary data using the `openssl_random_pseudo_bytes()` PHP function
20 *
21 * The use of this generator requires PHP to be compiled using the
22 * `--with-openssl` option.
23 *
24 * @deprecated The openssl_random_pseudo_bytes() function is not a reliable
25 * source of randomness. The default RandomBytesGenerator, which uses the
26 * random_bytes() function, is recommended as the safest and most reliable
27 * source of randomness.
28 * <em>This generator will be removed in ramsey/uuid 4.0.0.</em>
29 * @link http://php.net/openssl_random_pseudo_bytes
30 */
31 class OpenSslGenerator implements RandomGeneratorInterface
32 {
33 /**
34 * Generates a string of random binary data of the specified length
35 *
36 * @param integer $length The number of bytes of random binary data to generate
37 * @return string A binary string
38 */
39 public function generate($length)
40 {
41 return openssl_random_pseudo_bytes($length);
42 }
43 }