Skip to content

Commit e599ecf

Browse files
Fallback if we don't have openssl
1 parent 74ca5ad commit e599ecf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/RedisTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5461,8 +5461,17 @@ private function generateSessionId()
54615461
{
54625462
if (function_exists('session_create_id')) {
54635463
return session_create_id();
5464+
} else if (function_exists('random_bytes')) {
5465+
return bin2hex(random_bytes(8));
5466+
} else if (function_exists('openssl_random_pseudo_bytes')) {
5467+
return bin2hex(openssl_random_pseudo_bytes(8));
54645468
} else {
5465-
$encoded = bin2hex(openssl_random_pseudo_bytes(8));
5469+
/* Not cryptographically secure, but it doesn't need to be
5470+
* for the test. We just want an ID */
5471+
$encoded = '';
5472+
for ($c = 0; $c < 8; $c++) {
5473+
$encoded .= chr(rand(65, 90));
5474+
}
54665475
return $encoded;
54675476
}
54685477
}

0 commit comments

Comments
 (0)