3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Usage: Run this from the command line to generate a secure passphrase in the format * of stereotypical bottom keymashing. * * php bottom-responder.php | xclip * * Why? Because furries ruin everything, including bottom jokes. */ function random_str(int $length, string $charset): string { $c = strlen($charset) - 1; if ($c < 1) { throw new RangeException("Dumb"); } $pieces = []; for ($i = 0; $i < $length; ++$i) { $x = random_int(0, $c); array_push($pieces, $charset[$x]); } return implode($pieces); } /* 8 home row characters + 8 to 12 random letters + 4 home row characters Entropy estimates Lower end: 26.575 + 38.864 + 13.288 -> 78 bits Upper end: 26.575 + 58.296 + 13.288 -> 98 bits */ $x = random_int(8, 12); echo random_str(8, 'asdfghjkl;') . random_str($x, 'qwertyuiopasdfghjkl;zxcvbnm,.') . random_str(8, 'asdfghjkl;');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/crGhX
function name:  (null)
number of ops:  21
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                                   'random_int'
          1        SEND_VAL                                                     8
          2        SEND_VAL                                                     12
          3        DO_ICALL                                             $1      
          4        ASSIGN                                                       !0, $1
   33     5        INIT_FCALL                                                   'random_str'
          6        SEND_VAL                                                     8
          7        SEND_VAL                                                     'asdfghjkl%3B'
          8        DO_FCALL                                          0  $3      
          9        INIT_FCALL                                                   'random_str'
         10        SEND_VAR                                                     !0
         11        SEND_VAL                                                     'qwertyuiopasdfghjkl%3Bzxcvbnm%2C.'
         12        DO_FCALL                                          0  $4      
         13        CONCAT                                               ~5      $3, $4
         14        INIT_FCALL                                                   'random_str'
         15        SEND_VAL                                                     8
         16        SEND_VAL                                                     'asdfghjkl%3B'
         17        DO_FCALL                                          0  $6      
         18        CONCAT                                               ~7      ~5, $6
         19        ECHO                                                         ~7
         20      > RETURN                                                       1

Function random_str:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 14
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 14
Branch analysis from position: 27
Branch analysis from position: 14
filename:       /in/crGhX
function name:  random_str
number of ops:  32
compiled vars:  !0 = $length, !1 = $charset, !2 = $c, !3 = $pieces, !4 = $i, !5 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   11     2        STRLEN                                               ~6      !1
          3        SUB                                                  ~7      ~6, 1
          4        ASSIGN                                                       !2, ~7
   12     5        IS_SMALLER                                                   !2, 1
          6      > JMPZ                                                         ~9, ->11
   13     7    >   NEW                                                  $10     'RangeException'
          8        SEND_VAL_EX                                                  'Dumb'
          9        DO_FCALL                                          0          
         10      > THROW                                             0          $10
   15    11    >   ASSIGN                                                       !3, <array>
   16    12        ASSIGN                                                       !4, 0
         13      > JMP                                                          ->25
   17    14    >   INIT_FCALL                                                   'random_int'
         15        SEND_VAL                                                     0
         16        SEND_VAR                                                     !2
         17        DO_ICALL                                             $14     
         18        ASSIGN                                                       !5, $14
   18    19        INIT_FCALL                                                   'array_push'
         20        SEND_REF                                                     !3
         21        FETCH_DIM_R                                          ~16     !1, !5
         22        SEND_VAL                                                     ~16
         23        DO_ICALL                                                     
   16    24        PRE_INC                                                      !4
         25    >   IS_SMALLER                                                   !4, !0
         26      > JMPNZ                                                        ~19, ->14
   20    27    >   FRAMELESS_ICALL_1                implode             ~20     !3
         28        VERIFY_RETURN_TYPE                                           ~20
         29      > RETURN                                                       ~20
   21    30*       VERIFY_RETURN_TYPE                                           
         31*     > RETURN                                                       null

End of function random_str

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.52 ms | 1915 KiB | 18 Q