3v4l.org

run code in 500+ PHP versions simultaneously
<?php function b62e($str) { if(mb_check_encoding($str, 'ASCII')) { $out = ''; $len = strlen($str); for($i=0; $i<$len; $i+=8) { $chunk = substr($str, $i, 8); $outlen = ceil( strlen($chunk)*8/6 );// 8bit/char in, 6bits/char out, round up $hex = bin2hex($chunk);// gmp won't convert from binary, so go via hex $raw = gmp_strval(gmp_init(ltrim($hex, '0'), 16), 62);// gmp doesn't like leading 0s $out .= str_pad($raw, $outlen, '0', STR_PAD_LEFT); } return $out; } return false;// unicode chars not supported } function b62d($str) { if(mb_check_encoding($str, 'ASCII')) { $out = ''; $len = strlen($str); for ($i=0; $i<$len; $i+=11) { $chunk = substr($str, $i, 11); $outlen = floor( strlen($chunk)*6/8 ); //6bit/char in, 8bits/char out, round down $raw = gmp_strval(gmp_init(ltrim($chunk, '0'), 62), 16); //gmp doesn't like leading 0s $pad = str_pad($raw, $outlen * 2, '0', STR_PAD_LEFT); //double output length as as we're going via hex (4bits/char) $out .= pack('H*', $pad); //same as hex2bin } return $out; } return false;// unicode chars not supported } for($i=0; $i<999; $i++){ $encoded = b62e($i); $decoded = b62d($encoded); echo "\t".$i."\t--->\t".$encoded."\t--->\t".$decoded.PHP_EOL; }

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 2
Branch analysis from position: 20
Branch analysis from position: 2
filename:       /in/EBWIP
function name:  (null)
number of ops:  21
compiled vars:  !0 = $i, !1 = $encoded, !2 = $decoded
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   38     0  E >   ASSIGN                                                       !0, 0
          1      > JMP                                                          ->18
   39     2    >   INIT_FCALL                                                   'b62e'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !1, $4
   40     6        INIT_FCALL                                                   'b62d'
          7        SEND_VAR                                                     !1
          8        DO_FCALL                                          0  $6      
          9        ASSIGN                                                       !2, $6
   41    10        CONCAT                                               ~8      '%09', !0
         11        CONCAT                                               ~9      ~8, '%09---%3E%09'
         12        CONCAT                                               ~10     ~9, !1
         13        CONCAT                                               ~11     ~10, '%09---%3E%09'
         14        CONCAT                                               ~12     ~11, !2
         15        CONCAT                                               ~13     ~12, '%0A'
         16        ECHO                                                         ~13
   38    17        PRE_INC                                                      !0
         18    >   IS_SMALLER                                                   !0, 999
         19      > JMPNZ                                                        ~15, ->2
   42    20    > > RETURN                                                       1

Function b62e:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 49
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 11
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 11
Branch analysis from position: 48
Branch analysis from position: 11
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EBWIP
function name:  b62e
number of ops:  51
compiled vars:  !0 = $str, !1 = $out, !2 = $len, !3 = $i, !4 = $chunk, !5 = $outlen, !6 = $hex, !7 = $raw
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'mb_check_encoding'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     'ASCII'
          4        DO_ICALL                                             $8      
          5      > JMPZ                                                         $8, ->49
    5     6    >   ASSIGN                                                       !1, ''
    6     7        STRLEN                                               ~10     !0
          8        ASSIGN                                                       !2, ~10
    7     9        ASSIGN                                                       !3, 0
         10      > JMP                                                          ->46
    8    11    >   FRAMELESS_ICALL_3                substr              ~13     !0, !3
         12        OP_DATA                                                      8
         13        ASSIGN                                                       !4, ~13
    9    14        INIT_FCALL                                                   'ceil'
         15        STRLEN                                               ~15     !4
         16        MUL                                                  ~16     ~15, 8
         17        DIV                                                  ~17     ~16, 6
         18        SEND_VAL                                                     ~17
         19        DO_ICALL                                             $18     
         20        ASSIGN                                                       !5, $18
   10    21        INIT_FCALL                                                   'bin2hex'
         22        SEND_VAR                                                     !4
         23        DO_ICALL                                             $20     
         24        ASSIGN                                                       !6, $20
   11    25        INIT_FCALL_BY_NAME                                           'gmp_strval'
         26        INIT_FCALL_BY_NAME                                           'gmp_init'
         27        INIT_FCALL                                                   'ltrim'
         28        SEND_VAR                                                     !6
         29        SEND_VAL                                                     '0'
         30        DO_ICALL                                             $22     
         31        SEND_VAR_NO_REF_EX                                           $22
         32        SEND_VAL_EX                                                  16
         33        DO_FCALL                                          0  $23     
         34        SEND_VAR_NO_REF_EX                                           $23
         35        SEND_VAL_EX                                                  62
         36        DO_FCALL                                          0  $24     
         37        ASSIGN                                                       !7, $24
   12    38        INIT_FCALL                                                   'str_pad'
         39        SEND_VAR                                                     !7
         40        SEND_VAR                                                     !5
         41        SEND_VAL                                                     '0'
         42        SEND_VAL                                                     0
         43        DO_ICALL                                             $26     
         44        ASSIGN_OP                                         8          !1, $26
    7    45        ASSIGN_OP                                         1          !3, 8
         46    >   IS_SMALLER                                                   !3, !2
         47      > JMPNZ                                                        ~29, ->11
   14    48    > > RETURN                                                       !1
   16    49    > > RETURN                                                       <false>
   17    50*     > RETURN                                                       null

End of function b62e

Function b62d:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 51
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 11
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 11
Branch analysis from position: 50
Branch analysis from position: 11
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EBWIP
function name:  b62d
number of ops:  53
compiled vars:  !0 = $str, !1 = $out, !2 = $len, !3 = $i, !4 = $chunk, !5 = $outlen, !6 = $raw, !7 = $pad
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
   22     1        INIT_FCALL                                                   'mb_check_encoding'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     'ASCII'
          4        DO_ICALL                                             $8      
          5      > JMPZ                                                         $8, ->51
   23     6    >   ASSIGN                                                       !1, ''
   24     7        STRLEN                                               ~10     !0
          8        ASSIGN                                                       !2, ~10
   25     9        ASSIGN                                                       !3, 0
         10      > JMP                                                          ->48
   26    11    >   FRAMELESS_ICALL_3                substr              ~13     !0, !3
         12        OP_DATA                                                      11
         13        ASSIGN                                                       !4, ~13
   27    14        INIT_FCALL                                                   'floor'
         15        STRLEN                                               ~15     !4
         16        MUL                                                  ~16     ~15, 6
         17        DIV                                                  ~17     ~16, 8
         18        SEND_VAL                                                     ~17
         19        DO_ICALL                                             $18     
         20        ASSIGN                                                       !5, $18
   28    21        INIT_FCALL_BY_NAME                                           'gmp_strval'
         22        INIT_FCALL_BY_NAME                                           'gmp_init'
         23        INIT_FCALL                                                   'ltrim'
         24        SEND_VAR                                                     !4
         25        SEND_VAL                                                     '0'
         26        DO_ICALL                                             $20     
         27        SEND_VAR_NO_REF_EX                                           $20
         28        SEND_VAL_EX                                                  62
         29        DO_FCALL                                          0  $21     
         30        SEND_VAR_NO_REF_EX                                           $21
         31        SEND_VAL_EX                                                  16
         32        DO_FCALL                                          0  $22     
         33        ASSIGN                                                       !6, $22
   29    34        INIT_FCALL                                                   'str_pad'
         35        SEND_VAR                                                     !6
         36        MUL                                                  ~24     !5, 2
         37        SEND_VAL                                                     ~24
         38        SEND_VAL                                                     '0'
         39        SEND_VAL                                                     0
         40        DO_ICALL                                             $25     
         41        ASSIGN                                                       !7, $25
   30    42        INIT_FCALL                                                   'pack'
         43        SEND_VAL                                                     'H%2A'
         44        SEND_VAR                                                     !7
         45        DO_ICALL                                             $27     
         46        ASSIGN_OP                                         8          !1, $27
   25    47        ASSIGN_OP                                         1          !3, 11
         48    >   IS_SMALLER                                                   !3, !2
         49      > JMPNZ                                                        ~30, ->11
   32    50    > > RETURN                                                       !1
   34    51    > > RETURN                                                       <false>
   35    52*     > RETURN                                                       null

End of function b62d

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
182.29 ms | 6426 KiB | 22 Q