3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function crypto_rand_secure($min, $max) { $range = $max - $min; if ($range < 0) return $min; // not so random... $log = log($range, 2); $bytes = (int) ($log / 8) + 1; // length in bytes $bits = (int) $log + 1; // length in bits $filter = (int) (1 << $bits) - 1; // set all lower bits to 1 do { $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes))); $rnd = $rnd & $filter; // discard irrelevant bits } while ($rnd >= $range); return $min + $rnd; } function getToken($length){ $token = ""; $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $codeAlphabet.= "abcdefghijklmnopqrstuvwxyz"; $codeAlphabet.= "0123456789"; for($i=0;$i<$length;$i++){ $token .= $codeAlphabet[crypto_rand_secure(0,strlen($codeAlphabet))]; } return $token; } echo getToken(23);
Output for 7.1.0
sAk2RRacbg1Wi4UOfDqF3pN
Output for 7.0.14
Tp09vNiQ0iC78E9O2m7QRTu
Output for 7.0.6
mBlKSkY7FN1FIdmSAahvjzJ
Output for 7.0.5
DCy32ZFiXUyu5bURF0Em6Sl
Output for 7.0.4
ER1tF0VgWLPYqhWAt1EhSav
Output for 7.0.3
62FstSeu6MevOuAEzGIbRhx
Output for 7.0.2
gYRNPKmISgtaUBqSWitIw63
Output for 7.0.1
knA7stDJuICJl01qeLtN0rt
Output for 7.0.0
Oi1brkM9ZlYuxMt4jON6P8Q
Output for hhvm-3.12.0
otOTJFPMq4qQdqPrW32lWHJ
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.28
V7lYIZRuzJK61MTmlcPha4m
Output for 5.6.21
h0yZzdtFIbA6mEB52jmhM2l
Output for 5.6.20
kOolRg9j6dyWEbvQjZVQzNY
Output for 5.6.19
z5WzHy0X8Wf4JaDTLZQeRUE
Output for 5.6.18
XKXVCcjyUwdelaTY8T9rrpL
Output for 5.6.17
ucxsg2dvtBj6MngMQwlq5xY
Output for 5.6.16
2kGN7d2ltL39V5egnyRylfU
Output for 5.6.15
pftL2YuBnTwp267KdwqHtcq
Output for 5.6.14
9HAK78Otg3qMrphg8MzYaxv
Output for 5.6.13
Y0lrICVaJDednEG9KMiEh9c
Output for 5.6.12
r4nGx5493fDeZUXHQZZpDhP
Output for 5.6.11
AooaDoCFm5R7P0E3WMcZtf9
Output for 5.6.10
NGve52r27p2v6x6xSggobuq
Output for 5.6.9
MtMUd6aq9Hkx6PupTSO2wp8
Output for 5.6.8
Y1g3KjiLXatPDEFfIUFaHAc
Output for 5.5.35
3e13rDOs32h3H2XgFFDCagF
Output for 5.5.34
ffMA9uDgECTDPU5GOpLQTVC
Output for 5.5.33
vroVxYggVUSn7eXpsGtWGVY
Output for 5.5.32
BQEazussZNRaCaoNUZN7Jqc
Output for 5.5.31
u7Rib82ZkTrEqTXYPzQbIl6
Output for 5.5.30
uhe0K2G6VHnpEOM9uhh0QZV
Output for 5.5.29
q03sjw1FY2mOnLgykco5u4h
Output for 5.5.28
0XbKvWNruwVOr3tY0gRM2AQ
Output for 5.5.27
uWVsJUgFs0GQ1pcqK77zZng
Output for 5.5.26
daRzbhBtWiWk9EroVRuhBcT
Output for 5.5.25
3qmgsApzqtLkVTBqqZKnKEV
Output for 5.5.24
x7wHOmdiqlI9uGYvPNWczv9
Output for 5.4.45
st5rH7RuyxQyQSrOk63ZOBw
Output for 5.4.44
zzbIKY26J1Uks5ZH007cyym
Output for 5.4.43
ZHX69QCIq4dnonuCJx7Vssx
Output for 5.4.42
FpnfvZ98VsHkJTtz6yDaQMI
Output for 5.4.41
2Sji8OcXm6T0rwzfYZpMfUW
Output for 5.4.40
f40c0YYqQ7efJB2aiMEXM6k
Output for 5.4.39
HbKB5cCwKRMAgpFF5O2MJOF
Output for 5.4.38
M4WMgrRO2MHeZXWXayb3FTR
Output for 5.4.37
03ykDzKkPlSb3zi1lAaRFhw
Output for 5.4.36
J8B2kpbhWzDPALE6c6n0KrG
Output for 5.0.0 - 5.4.35
Fatal error: Call to undefined function openssl_random_pseudo_bytes() in /in/ESACQ on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/ESACQ on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/ESACQ on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/ESACQ on line 10