3v4l.org

run code in 300+ 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 = 52
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 11
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 11
Branch analysis from position: 51
Branch analysis from position: 11
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EBWIP
function name:  b62e
number of ops:  54
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, ->52
    5     6    >   ASSIGN                                                   !1, ''
    6     7        STRLEN                                           ~10     !0
          8        ASSIGN                                                   !2, ~10
    7     9        ASSIGN                                                   !3, 0
         10      > JMP                                                      ->49
    8    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !3
         14        SEND_VAL                                                 8
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !4, $13
    9    17        INIT_FCALL                                               'ceil'
         18        STRLEN                                           ~15     !4
         19        MUL                                              ~16     ~15, 8
         20        DIV                                              ~17     ~16, 6
         21        SEND_VAL                                                 ~17
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !5, $18
   10    24        INIT_FCALL                                               'bin2hex'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $20     
         27        ASSIGN                                                   !6, $20
   11    28        INIT_FCALL_BY_NAME                                       'gmp_strval'
         29        INIT_FCALL_BY_NAME                                       'gmp_init'
         30        INIT_FCALL                                               'ltrim'
         31        SEND_VAR                                                 !6
         32        SEND_VAL                                                 '0'
         33        DO_ICALL                                         $22     
         34        SEND_VAR_NO_REF_EX                                       $22
         35        SEND_VAL_EX                                              16
         36        DO_FCALL                                      0  $23     
         37        SEND_VAR_NO_REF_EX                                       $23
         38        SEND_VAL_EX                                              62
         39        DO_FCALL                                      0  $24     
         40        ASSIGN                                                   !7, $24
   12    41        INIT_FCALL                                               'str_pad'
         42        SEND_VAR                                                 !7
         43        SEND_VAR                                                 !5
         44        SEND_VAL                                                 '0'
         45        SEND_VAL                                                 0
         46        DO_ICALL                                         $26     
         47        ASSIGN_OP                                     8          !1, $26
    7    48        ASSIGN_OP                                     1          !3, 8
         49    >   IS_SMALLER                                               !3, !2
         50      > JMPNZ                                                    ~29, ->11
   14    51    > > RETURN                                                   !1
   16    52    > > RETURN                                                   <false>
   17    53*     > 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 = 54
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 11
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 11
Branch analysis from position: 53
Branch analysis from position: 11
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EBWIP
function name:  b62d
number of ops:  56
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, ->54
   23     6    >   ASSIGN                                                   !1, ''
   24     7        STRLEN                                           ~10     !0
          8        ASSIGN                                                   !2, ~10
   25     9        ASSIGN                                                   !3, 0
         10      > JMP                                                      ->51
   26    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !3
         14        SEND_VAL                                                 11
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !4, $13
   27    17        INIT_FCALL                                               'floor'
         18        STRLEN                                           ~15     !4
         19        MUL                                              ~16     ~15, 6
         20        DIV                                              ~17     ~16, 8
         21        SEND_VAL                                                 ~17
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !5, $18
   28    24        INIT_FCALL_BY_NAME                                       'gmp_strval'
         25        INIT_FCALL_BY_NAME                                       'gmp_init'
         26        INIT_FCALL                                               'ltrim'
         27        SEND_VAR                                                 !4
         28        SEND_VAL                                                 '0'
         29        DO_ICALL                                         $20     
         30        SEND_VAR_NO_REF_EX                                       $20
         31        SEND_VAL_EX                                              62
         32        DO_FCALL                                      0  $21     
         33        SEND_VAR_NO_REF_EX                                       $21
         34        SEND_VAL_EX                                              16
         35        DO_FCALL                                      0  $22     
         36        ASSIGN                                                   !6, $22
   29    37        INIT_FCALL                                               'str_pad'
         38        SEND_VAR                                                 !6
         39        MUL                                              ~24     !5, 2
         40        SEND_VAL                                                 ~24
         41        SEND_VAL                                                 '0'
         42        SEND_VAL                                                 0
         43        DO_ICALL                                         $25     
         44        ASSIGN                                                   !7, $25
   30    45        INIT_FCALL                                               'pack'
         46        SEND_VAL                                                 'H%2A'
         47        SEND_VAR                                                 !7
         48        DO_ICALL                                         $27     
         49        ASSIGN_OP                                     8          !1, $27
   25    50        ASSIGN_OP                                     1          !3, 11
         51    >   IS_SMALLER                                               !3, !2
         52      > JMPNZ                                                    ~30, ->11
   32    53    > > RETURN                                                   !1
   34    54    > > RETURN                                                   <false>
   35    55*     > RETURN                                                   null

End of function b62d

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.81 ms | 1021 KiB | 23 Q