3v4l.org

run code in 300+ PHP versions simultaneously
<?php function OTP($input, $pad) { $inputlen = strlen($input); $padlen = strlen($pad); $inputbytes = unpack("C*", $input); //Pack C* will convert a string into a byte array, such as 'abc' to Array(0x61, 0x62, 0x63) $padbytes = unpack("C*", $pad); $output = ""; for($i = 0; $i < $inputlen; $i++) //Loop through the input string $output .= chr($inputbytes[$i + 1] ^ $padbytes[$i % $padlen + 1]); return $output; } $result = OTP("This is a long sentence", "Abc"); var_dump(unpack("C*", $result)); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gebpq
function name:  (null)
number of ops:  16
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'otp'
          1        SEND_VAL                                                 'This+is+a+long+sentence'
          2        SEND_VAL                                                 'Abc'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   16     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'unpack'
          7        SEND_VAL                                                 'C%2A'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                                 
   17    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function otp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
Branch analysis from position: 19
filename:       /in/Gebpq
function name:  OTP
number of ops:  34
compiled vars:  !0 = $input, !1 = $pad, !2 = $inputlen, !3 = $padlen, !4 = $inputbytes, !5 = $padbytes, !6 = $output, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        STRLEN                                           ~8      !0
          3        ASSIGN                                                   !2, ~8
    5     4        STRLEN                                           ~10     !1
          5        ASSIGN                                                   !3, ~10
    6     6        INIT_FCALL                                               'unpack'
          7        SEND_VAL                                                 'C%2A'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $12     
         10        ASSIGN                                                   !4, $12
    7    11        INIT_FCALL                                               'unpack'
         12        SEND_VAL                                                 'C%2A'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !5, $14
    9    16        ASSIGN                                                   !6, ''
   10    17        ASSIGN                                                   !7, 0
         18      > JMP                                                      ->30
   11    19    >   INIT_FCALL                                               'chr'
         20        ADD                                              ~18     !7, 1
         21        FETCH_DIM_R                                      ~19     !4, ~18
         22        MOD                                              ~20     !7, !3
         23        ADD                                              ~21     ~20, 1
         24        FETCH_DIM_R                                      ~22     !5, ~21
         25        BW_XOR                                           ~23     ~19, ~22
         26        SEND_VAL                                                 ~23
         27        DO_ICALL                                         $24     
         28        ASSIGN_OP                                     8          !6, $24
   10    29        PRE_INC                                                  !7
         30    >   IS_SMALLER                                               !7, !2
         31      > JMPNZ                                                    ~27, ->19
   12    32    > > RETURN                                                   !6
   13    33*     > RETURN                                                   null

End of function otp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.34 ms | 1403 KiB | 20 Q