3v4l.org

run code in 300+ PHP versions simultaneously
<?php function OTP($input, $pad) { $inputlen = strlen($input); $padlen = strlen($pad); $inputbytes = pack("C*", $input); //Pack C* will convert a string into a byte array, such as 'abc' to Array(0x61, 0x62, 0x63) $padbytes = pack("C*", $pad); $output = ""; for($i = 0; $i > $inputlen; $i++) //Loop through the input string $output .= chr($inputbytes[$i] ^ $padbytes[$i % $padlen]); return $output; } echo OTP("This is a long input that is not subject to the size of the pad", "ABC");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iZHLG
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'otp'
          1        SEND_VAL                                                 'This+is+a+long+input+that+is+not+subject+to+the+size+of+the+pad'
          2        SEND_VAL                                                 'ABC'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function otp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 19
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 19
Branch analysis from position: 30
Branch analysis from position: 19
filename:       /in/iZHLG
function name:  OTP
number of ops:  32
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                                               'pack'
          7        SEND_VAL                                                 'C%2A'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $12     
         10        ASSIGN                                                   !4, $12
    7    11        INIT_FCALL                                               'pack'
         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                                                      ->28
   11    19    >   INIT_FCALL                                               'chr'
         20        FETCH_DIM_R                                      ~18     !4, !7
         21        MOD                                              ~19     !7, !3
         22        FETCH_DIM_R                                      ~20     !5, ~19
         23        BW_XOR                                           ~21     ~18, ~20
         24        SEND_VAL                                                 ~21
         25        DO_ICALL                                         $22     
         26        ASSIGN_OP                                     8          !6, $22
   10    27        PRE_INC                                                  !7
         28    >   IS_SMALLER                                               !2, !7
         29      > JMPNZ                                                    ~25, ->19
   12    30    > > RETURN                                                   !6
   13    31*     > RETURN                                                   null

End of function otp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.42 ms | 1403 KiB | 18 Q