3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } getToken(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QcFBA
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'gettoken'
          1        DO_FCALL                                      0          
   28     2      > RETURN                                                   1

Function crypto_rand_secure:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 23
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/QcFBA
function name:  crypto_rand_secure
number of ops:  40
compiled vars:  !0 = $min, !1 = $max, !2 = $range, !3 = $log, !4 = $bytes, !5 = $bits, !6 = $filter, !7 = $rnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        SUB                                              ~8      !1, !0
          3        ASSIGN                                                   !2, ~8
    4     4        IS_SMALLER                                               !2, 0
          5      > JMPZ                                                     ~10, ->7
          6    > > RETURN                                                   !0
    5     7    >   INIT_FCALL                                               'log'
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 2
         10        DO_ICALL                                         $11     
         11        ASSIGN                                                   !3, $11
    6    12        DIV                                              ~13     !3, 8
         13        CAST                                          4  ~14     ~13
         14        ADD                                              ~15     ~14, 1
         15        ASSIGN                                                   !4, ~15
    7    16        CAST                                          4  ~17     !3
         17        ADD                                              ~18     ~17, 1
         18        ASSIGN                                                   !5, ~18
    8    19        SL                                               ~20     1, !5
         20        CAST                                          4  ~21     ~20
         21        SUB                                              ~22     ~21, 1
         22        ASSIGN                                                   !6, ~22
   10    23    >   INIT_FCALL                                               'hexdec'
         24        INIT_FCALL                                               'bin2hex'
         25        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0  $24     
         28        SEND_VAR                                                 $24
         29        DO_ICALL                                         $25     
         30        SEND_VAR                                                 $25
         31        DO_ICALL                                         $26     
         32        ASSIGN                                                   !7, $26
   11    33        BW_AND                                           ~28     !7, !6
         34        ASSIGN                                                   !7, ~28
   12    35        IS_SMALLER_OR_EQUAL                                      !2, !7
         36      > JMPNZ                                                    ~30, ->23
   13    37    >   ADD                                              ~31     !0, !7
         38      > RETURN                                                   ~31
   14    39*     > RETURN                                                   null

End of function crypto_rand_secure

Function gettoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
Branch analysis from position: 7
filename:       /in/QcFBA
function name:  getToken
number of ops:  19
compiled vars:  !0 = $length, !1 = $token, !2 = $codeAlphabet, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        ASSIGN                                                   !1, ''
   18     2        ASSIGN                                                   !2, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   19     3        ASSIGN_OP                                     8          !2, 'abcdefghijklmnopqrstuvwxyz'
   20     4        ASSIGN_OP                                     8          !2, '0123456789'
   21     5        ASSIGN                                                   !3, 0
          6      > JMP                                                      ->15
   22     7    >   INIT_FCALL                                               'crypto_rand_secure'
          8        SEND_VAL                                                 0
          9        STRLEN                                           ~9      !2
         10        SEND_VAL                                                 ~9
         11        DO_FCALL                                      0  $10     
         12        FETCH_DIM_R                                      ~11     !2, $10
         13        ASSIGN_OP                                     8          !1, ~11
   21    14        PRE_INC                                                  !3
         15    >   IS_SMALLER                                               !3, !0
         16      > JMPNZ                                                    ~14, ->7
   24    17    > > RETURN                                                   !1
   25    18*     > RETURN                                                   null

End of function gettoken

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.99 ms | 1394 KiB | 21 Q