3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!defined('PHP_EOL')) { define('PHP_EOL', "\r\n"); } // generate the 32bit byte array (if you have the "openssl_random_pseudo_bytes" function available) if (function_exists('openssl_random_pseudo_bytes')) { $random_key = openssl_random_pseudo_bytes(32); } else { // this is the longer way to do it... $random_key = ''; for( $i = 0; $i < 64; $i++) { $random_key .= ((bool)rand(0, 1) ? chr(rand(65, 90)) : rand(0, 9)); } $random_key = hexdec($random_key); } // this is it as hex print "Hex key: " . bin2hex($random_key) . PHP_EOL; print PHP_EOL; // this is the base64 string that you want to save print "Save this string: " . base64_encode($random_key) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 5
Branch analysis from position: 1
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 17
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 17
Branch analysis from position: 41
Branch analysis from position: 17
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 17
Branch analysis from position: 41
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/DquvQ
function name:  (null)
number of ops:  59
compiled vars:  !0 = $random_key, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E > > JMPZ                                                     <false>, ->5
    4     1    >   INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'PHP_EOL'
          3        SEND_VAL                                                 '%0D%0A'
          4        DO_ICALL                                                 
    8     5    >   INIT_FCALL                                               'function_exists'
          6        SEND_VAL                                                 'openssl_random_pseudo_bytes'
          7        DO_ICALL                                         $3      
          8      > JMPZ                                                     $3, ->14
    9     9    >   INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
         10        SEND_VAL_EX                                              32
         11        DO_FCALL                                      0  $4      
         12        ASSIGN                                                   !0, $4
         13      > JMP                                                      ->45
   12    14    >   ASSIGN                                                   !0, ''
   13    15        ASSIGN                                                   !1, 0
         16      > JMP                                                      ->39
   14    17    >   INIT_FCALL                                               'rand'
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $8      
         21        BOOL                                             ~9      $8
         22      > JMPZ                                                     ~9, ->32
         23    >   INIT_FCALL                                               'chr'
         24        INIT_FCALL                                               'rand'
         25        SEND_VAL                                                 65
         26        SEND_VAL                                                 90
         27        DO_ICALL                                         $10     
         28        SEND_VAR                                                 $10
         29        DO_ICALL                                         $11     
         30        QM_ASSIGN                                        ~12     $11
         31      > JMP                                                      ->37
         32    >   INIT_FCALL                                               'rand'
         33        SEND_VAL                                                 0
         34        SEND_VAL                                                 9
         35        DO_ICALL                                         $13     
         36        QM_ASSIGN                                        ~12     $13
         37    >   ASSIGN_OP                                     8          !0, ~12
   13    38        PRE_INC                                                  !1
         39    >   IS_SMALLER                                               !1, 64
         40      > JMPNZ                                                    ~16, ->17
   16    41    >   INIT_FCALL                                               'hexdec'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $17     
         44        ASSIGN                                                   !0, $17
   20    45    >   INIT_FCALL                                               'bin2hex'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                         $19     
         48        CONCAT                                           ~20     'Hex+key%3A+', $19
         49        CONCAT                                           ~21     ~20, '%0A'
         50        ECHO                                                     ~21
   22    51        ECHO                                                     '%0A'
   25    52        INIT_FCALL                                               'base64_encode'
         53        SEND_VAR                                                 !0
         54        DO_ICALL                                         $22     
         55        CONCAT                                           ~23     'Save+this+string%3A+', $22
         56        CONCAT                                           ~24     ~23, '%0A'
         57        ECHO                                                     ~24
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.49 ms | 1400 KiB | 27 Q