3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string,$i,1)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } return $hash; } function decode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i+=2) { $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= chr($ordStr - $ordKey); } return $hash; } echo encode("Please Encode Me!","This is a key"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hEsVF
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'encode'
          1        SEND_VAL                                                 'Please+Encode+Me%21'
          2        SEND_VAL                                                 'This+is+a+key'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   30     5      > RETURN                                                   1

Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 12
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 12
Branch analysis from position: 50
Branch analysis from position: 12
Branch analysis from position: 24
filename:       /in/hEsVF
function name:  encode
number of ops:  52
compiled vars:  !0 = $string, !1 = $key, !2 = $strLen, !3 = $keyLen, !4 = $i, !5 = $ordStr, !6 = $j, !7 = $ordKey, !8 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'sha1'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
    4     6        STRLEN                                           ~11     !0
          7        ASSIGN                                                   !2, ~11
    5     8        STRLEN                                           ~13     !1
          9        ASSIGN                                                   !3, ~13
    6    10        ASSIGN                                                   !4, 0
         11      > JMP                                                      ->48
    7    12    >   INIT_FCALL                                               'ord'
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !4
         16        SEND_VAL                                                 1
         17        DO_ICALL                                         $16     
         18        SEND_VAR                                                 $16
         19        DO_ICALL                                         $17     
         20        ASSIGN                                                   !5, $17
    8    21        IS_EQUAL                                                 !6, !3
         22      > JMPZ                                                     ~19, ->24
         23    >   ASSIGN                                                   !6, 0
    9    24    >   INIT_FCALL                                               'ord'
         25        INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !1
         27        SEND_VAR                                                 !6
         28        SEND_VAL                                                 1
         29        DO_ICALL                                         $21     
         30        SEND_VAR                                                 $21
         31        DO_ICALL                                         $22     
         32        ASSIGN                                                   !7, $22
   10    33        PRE_INC                                                  !6
   11    34        INIT_FCALL                                               'strrev'
         35        INIT_FCALL                                               'base_convert'
         36        INIT_FCALL                                               'dechex'
         37        ADD                                              ~25     !5, !7
         38        SEND_VAL                                                 ~25
         39        DO_ICALL                                         $26     
         40        SEND_VAR                                                 $26
         41        SEND_VAL                                                 16
         42        SEND_VAL                                                 36
         43        DO_ICALL                                         $27     
         44        SEND_VAR                                                 $27
         45        DO_ICALL                                         $28     
         46        ASSIGN_OP                                     8          !8, $28
    6    47        PRE_INC                                                  !4
         48    >   IS_SMALLER                                               !4, !2
         49      > JMPNZ                                                    ~31, ->12
   13    50    > > RETURN                                                   !8
   14    51*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 12
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 12
Branch analysis from position: 50
Branch analysis from position: 12
Branch analysis from position: 32
filename:       /in/hEsVF
function name:  decode
number of ops:  52
compiled vars:  !0 = $string, !1 = $key, !2 = $strLen, !3 = $keyLen, !4 = $i, !5 = $ordStr, !6 = $j, !7 = $ordKey, !8 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_FCALL                                               'sha1'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
   18     6        STRLEN                                           ~11     !0
          7        ASSIGN                                                   !2, ~11
   19     8        STRLEN                                           ~13     !1
          9        ASSIGN                                                   !3, ~13
   20    10        ASSIGN                                                   !4, 0
         11      > JMP                                                      ->48
   21    12    >   INIT_FCALL                                               'hexdec'
         13        INIT_FCALL                                               'base_convert'
         14        INIT_FCALL                                               'strrev'
         15        INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !4
         18        SEND_VAL                                                 2
         19        DO_ICALL                                         $16     
         20        SEND_VAR                                                 $16
         21        DO_ICALL                                         $17     
         22        SEND_VAR                                                 $17
         23        SEND_VAL                                                 36
         24        SEND_VAL                                                 16
         25        DO_ICALL                                         $18     
         26        SEND_VAR                                                 $18
         27        DO_ICALL                                         $19     
         28        ASSIGN                                                   !5, $19
   22    29        IS_EQUAL                                                 !6, !3
         30      > JMPZ                                                     ~21, ->32
         31    >   ASSIGN                                                   !6, 0
   23    32    >   INIT_FCALL                                               'ord'
         33        INIT_FCALL                                               'substr'
         34        SEND_VAR                                                 !1
         35        SEND_VAR                                                 !6
         36        SEND_VAL                                                 1
         37        DO_ICALL                                         $23     
         38        SEND_VAR                                                 $23
         39        DO_ICALL                                         $24     
         40        ASSIGN                                                   !7, $24
   24    41        PRE_INC                                                  !6
   25    42        INIT_FCALL                                               'chr'
         43        SUB                                              ~27     !5, !7
         44        SEND_VAL                                                 ~27
         45        DO_ICALL                                         $28     
         46        ASSIGN_OP                                     8          !8, $28
   20    47        ASSIGN_OP                                     1          !4, 2
         48    >   IS_SMALLER                                               !4, !2
         49      > JMPNZ                                                    ~31, ->12
   27    50    > > RETURN                                                   !8
   28    51*     > RETURN                                                   null

End of function decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.09 ms | 1407 KiB | 30 Q