3v4l.org

run code in 300+ PHP versions simultaneously
<?php $secret = 'MB4CMFCCGLNNAC4WR5AOGFVJZR4IIAD7'; function binaryChunk($binaryString, $bits) { $binaryString = chunk_split($binaryString, $bits, ' '); if (substr($binaryString, (strlen($binaryString)) - 1) == ' ') { $binaryString = substr($binaryString, 0, strlen($binaryString)-1); } return explode(' ', $binaryString); } function base32decode($base32String){ $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567='; // Only work in upper cases $base32String = strtoupper($base32String); // Remove anything that is not base32 alphabet $pattern = '/[^A-Z2-7]/'; $base32String = preg_replace($pattern, '', $base32String); if (strlen($base32String) == 0) { // Gives an empty string return ''; } $base32Array = str_split($base32String); $string = ''; foreach ($base32Array as $str) { $char = strpos($alphabet, $str); // Ignore the padding character if ($char !== 32) { $string .= sprintf('%05b', $char); } } while (strlen($string) %8 !== 0) { $string = substr($string, 0, strlen($string)-1); } $binaryArray = binaryChunk($string, 8); $realString = ''; foreach ($binaryArray as $bin) { // Pad each value to 8 bits $bin = str_pad($bin, 8, 0, STR_PAD_RIGHT); // Convert binary strings to ASCII $realString .= chr(bindec($bin)); } return $realString; } $bin = base32decode($secret); $rnd = bin2hex($bin); echo $rnd;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GRjjM
function name:  (null)
number of ops:  11
compiled vars:  !0 = $secret, !1 = $bin, !2 = $rnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'MB4CMFCCGLNNAC4WR5AOGFVJZR4IIAD7'
   48     1        INIT_FCALL                                               'base32decode'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   49     5        INIT_FCALL                                               'bin2hex'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   51     9        ECHO                                                     !2
   52    10      > RETURN                                                   1

Function binarychunk:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/GRjjM
function name:  binaryChunk
number of ops:  30
compiled vars:  !0 = $binaryString, !1 = $bits
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'chunk_split'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 '+'
          6        DO_ICALL                                         $2      
          7        ASSIGN                                                   !0, $2
    7     8        INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        STRLEN                                           ~4      !0
         11        SUB                                              ~5      ~4, 1
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                         $6      
         14        IS_EQUAL                                                 $6, '+'
         15      > JMPZ                                                     ~7, ->24
    8    16    >   INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 0
         19        STRLEN                                           ~8      !0
         20        SUB                                              ~9      ~8, 1
         21        SEND_VAL                                                 ~9
         22        DO_ICALL                                         $10     
         23        ASSIGN                                                   !0, $10
   10    24    >   INIT_FCALL                                               'explode'
         25        SEND_VAL                                                 '+'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $12     
         28      > RETURN                                                   $12
   11    29*     > RETURN                                                   null

End of function binarychunk

Function base32decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 37
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 36
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 39
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 58, Position 2 = 74
Branch analysis from position: 58
2 jumps found. (Code = 78) Position 1 = 59, Position 2 = 74
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 39
Branch analysis from position: 51
Branch analysis from position: 39
Branch analysis from position: 37
filename:       /in/GRjjM
function name:  base32decode
number of ops:  77
compiled vars:  !0 = $base32String, !1 = $alphabet, !2 = $pattern, !3 = $base32Array, !4 = $string, !5 = $str, !6 = $char, !7 = $binaryArray, !8 = $realString, !9 = $bin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN                                                   !1, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567%3D'
   17     2        INIT_FCALL                                               'strtoupper'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $11     
          5        ASSIGN                                                   !0, $11
   19     6        ASSIGN                                                   !2, '%2F%5B%5EA-Z2-7%5D%2F'
   20     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 ''
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $14     
         12        ASSIGN                                                   !0, $14
   21    13        STRLEN                                           ~16     !0
         14        IS_EQUAL                                                 ~16, 0
         15      > JMPZ                                                     ~17, ->17
   23    16    > > RETURN                                                   ''
   25    17    >   INIT_FCALL                                               'str_split'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $18     
         20        ASSIGN                                                   !3, $18
   26    21        ASSIGN                                                   !4, ''
   27    22      > FE_RESET_R                                       $21     !3, ->37
         23    > > FE_FETCH_R                                               $21, !5, ->37
   28    24    >   INIT_FCALL                                               'strpos'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                         $22     
         28        ASSIGN                                                   !6, $22
   30    29        IS_NOT_IDENTICAL                                         !6, 32
         30      > JMPZ                                                     ~24, ->36
   31    31    >   INIT_FCALL                                               'sprintf'
         32        SEND_VAL                                                 '%2505b'
         33        SEND_VAR                                                 !6
         34        DO_ICALL                                         $25     
         35        ASSIGN_OP                                     8          !4, $25
   27    36    > > JMP                                                      ->23
         37    >   FE_FREE                                                  $21
   34    38      > JMP                                                      ->47
   35    39    >   INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !4
         41        SEND_VAL                                                 0
         42        STRLEN                                           ~27     !4
         43        SUB                                              ~28     ~27, 1
         44        SEND_VAL                                                 ~28
         45        DO_ICALL                                         $29     
         46        ASSIGN                                                   !4, $29
   34    47    >   STRLEN                                           ~31     !4
         48        MOD                                              ~32     ~31, 8
         49        IS_NOT_IDENTICAL                                         ~32, 0
         50      > JMPNZ                                                    ~33, ->39
   37    51    >   INIT_FCALL                                               'binarychunk'
         52        SEND_VAR                                                 !4
         53        SEND_VAL                                                 8
         54        DO_FCALL                                      0  $34     
         55        ASSIGN                                                   !7, $34
   38    56        ASSIGN                                                   !8, ''
   39    57      > FE_RESET_R                                       $37     !7, ->74
         58    > > FE_FETCH_R                                               $37, !9, ->74
   41    59    >   INIT_FCALL                                               'str_pad'
         60        SEND_VAR                                                 !9
         61        SEND_VAL                                                 8
         62        SEND_VAL                                                 0
         63        SEND_VAL                                                 1
         64        DO_ICALL                                         $38     
         65        ASSIGN                                                   !9, $38
   43    66        INIT_FCALL                                               'chr'
         67        INIT_FCALL                                               'bindec'
         68        SEND_VAR                                                 !9
         69        DO_ICALL                                         $40     
         70        SEND_VAR                                                 $40
         71        DO_ICALL                                         $41     
         72        ASSIGN_OP                                     8          !8, $41
   39    73      > JMP                                                      ->58
         74    >   FE_FREE                                                  $37
   45    75      > RETURN                                                   !8
   46    76*     > RETURN                                                   null

End of function base32decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.29 ms | 1411 KiB | 39 Q