|
static | getBytes ($length) |
| Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback. More...
|
|
static | getBytes ($length) |
| Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback. More...
|
|
Definition at line 9 of file class.ilPasswordUtils.php.
◆ getBytes() [1/2]
static ilPasswordUtils::getBytes |
( |
|
$length | ) |
|
|
static |
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
- Parameters
-
- Returns
- string A byte string
Definition at line 16 of file class.ilPasswordUtils.php.
References $i, and defined.
Referenced by ilUserPasswordManager\encodePassword(), ilBcryptPasswordEncoder\generateClientSalt(), and ilSimpleSAMLphpWrapper\initConfigFiles().
18 if (!
defined(
'PHP_WINDOWS_VERSION_BUILD') && extension_loaded(
'openssl')) {
20 $rand = openssl_random_pseudo_bytes($length, $secure);
21 if (
false !== $rand && $secure ===
true) {
26 if (extension_loaded(
'mcrypt')) {
30 strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN' ||
31 version_compare(PHP_VERSION,
'5.3.7') >= 0
33 $rand = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
34 if ($rand !==
false && strlen($rand) === $length) {
42 for (
$i = 0;
$i < $length;
$i++) {
43 $rand .= chr(mt_rand(0, 255));
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
◆ getBytes() [2/2]
static ilPasswordUtils::getBytes |
( |
|
$length | ) |
|
|
static |
Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback.
- Parameters
-
- Returns
- string A byte string
Definition at line 16 of file class.ilPasswordUtils.php.
References $i, and defined.
18 if (!
defined(
'PHP_WINDOWS_VERSION_BUILD') && extension_loaded(
'openssl')) {
20 $rand = openssl_random_pseudo_bytes($length, $secure);
21 if (
false !== $rand && $secure ===
true) {
26 if (extension_loaded(
'mcrypt')) {
30 strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN' ||
31 version_compare(PHP_VERSION,
'5.3.7') >= 0
33 $rand = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
34 if ($rand !==
false && strlen($rand) === $length) {
42 for (
$i = 0;
$i < $length;
$i++) {
43 $rand .= chr(mt_rand(0, 255));
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
The documentation for this class was generated from the following file: