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 .= chr(mt_rand(65, 90)); } $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 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 17
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 17
Branch analysis from position: 28
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/5T8U8
function name:  (null)
number of ops:  46
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                                                      ->32
   12    14    >   ASSIGN                                                   !0, ''
   13    15        ASSIGN                                                   !1, 0
         16      > JMP                                                      ->26
   14    17    >   INIT_FCALL                                               'chr'
         18        INIT_FCALL                                               'mt_rand'
         19        SEND_VAL                                                 65
         20        SEND_VAL                                                 90
         21        DO_ICALL                                         $8      
         22        SEND_VAR                                                 $8
         23        DO_ICALL                                         $9      
         24        ASSIGN_OP                                     8          !0, $9
   13    25        PRE_INC                                                  !1
         26    >   IS_SMALLER                                               !1, 64
         27      > JMPNZ                                                    ~12, ->17
   16    28    >   INIT_FCALL                                               'hexdec'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $13     
         31        ASSIGN                                                   !0, $13
   20    32    >   INIT_FCALL                                               'bin2hex'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $15     
         35        CONCAT                                           ~16     'Hex+key%3A+', $15
         36        CONCAT                                           ~17     ~16, '%0A'
         37        ECHO                                                     ~17
   22    38        ECHO                                                     '%0A'
   25    39        INIT_FCALL                                               'base64_encode'
         40        SEND_VAR                                                 !0
         41        DO_ICALL                                         $18     
         42        CONCAT                                           ~19     'Save+this+string%3A+', $18
         43        CONCAT                                           ~20     ~19, '%0A'
         44        ECHO                                                     ~20
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.07 ms | 1400 KiB | 27 Q