3v4l.org

run code in 300+ PHP versions simultaneously
<?php function base64url_encode($data) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } function base64url_decode($data) { return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); } function encryptCode($data){ return mcrypt_encrypt( MCRYPT_DES , '12345678' , $data , 'cbc' ,'87654321'); } function decryptCode($data){ return mcrypt_decrypt( MCRYPT_DES , '12345678' , $data , 'cbc' ,'87654321'); } $id = 'Q2JmDpmqjNmGT4FJ2EkXXITOgc31ZA52'; $base64Decoded = base64url_decode($id); $decrypted = decryptCode($base64Decoded); print_r($decrypted."\n"); print_r("\n\n"); # Make the new plaintext string $toAdd = 'hellothere'; $additionalCipherText = encryptCode($toAdd); $additionalEncoded = base64url_encode($additionalCipherText); print_r("Additional cipher text:".$additionalEncoded."\n"); print_r("\n\n"); # Concatenate the plaintext and encrypt $plaintext = $decrypted.$toAdd; $cipherText = encryptCode($plaintext); $base64Encoded = base64url_encode($cipherText); print_r(" New cipher text: ".$base64Encoded."\n"); print_r("Original cipher text: ".$id.$additionalEncoded."\n"); # Try the reverse order $plaintext = $toAdd.$decrypted; $cipherText = encryptCode($plaintext); $base64Encoded = base64url_encode($cipherText); print_r(" New cipher text: ".$base64Encoded."\n"); print_r("Original cipher text: ".$additionalEncoded.$id."\n");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nv7UJ
function name:  (null)
number of ops:  76
compiled vars:  !0 = $id, !1 = $base64Decoded, !2 = $decrypted, !3 = $toAdd, !4 = $additionalCipherText, !5 = $additionalEncoded, !6 = $plaintext, !7 = $cipherText, !8 = $base64Encoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 'Q2JmDpmqjNmGT4FJ2EkXXITOgc31ZA52'
   20     1        INIT_FCALL                                               'base64url_decode'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $10     
          4        ASSIGN                                                   !1, $10
   21     5        INIT_FCALL                                               'decryptcode'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $12     
          8        ASSIGN                                                   !2, $12
   22     9        INIT_FCALL                                               'print_r'
         10        CONCAT                                           ~14     !2, '%0A'
         11        SEND_VAL                                                 ~14
         12        DO_ICALL                                                 
   23    13        INIT_FCALL                                               'print_r'
         14        SEND_VAL                                                 '%0A%0A'
         15        DO_ICALL                                                 
   26    16        ASSIGN                                                   !3, 'hellothere'
   27    17        INIT_FCALL                                               'encryptcode'
         18        SEND_VAR                                                 !3
         19        DO_FCALL                                      0  $18     
         20        ASSIGN                                                   !4, $18
   28    21        INIT_FCALL                                               'base64url_encode'
         22        SEND_VAR                                                 !4
         23        DO_FCALL                                      0  $20     
         24        ASSIGN                                                   !5, $20
   29    25        INIT_FCALL                                               'print_r'
         26        CONCAT                                           ~22     'Additional+cipher+text%3A', !5
         27        CONCAT                                           ~23     ~22, '%0A'
         28        SEND_VAL                                                 ~23
         29        DO_ICALL                                                 
   30    30        INIT_FCALL                                               'print_r'
         31        SEND_VAL                                                 '%0A%0A'
         32        DO_ICALL                                                 
   33    33        CONCAT                                           ~26     !2, !3
         34        ASSIGN                                                   !6, ~26
   34    35        INIT_FCALL                                               'encryptcode'
         36        SEND_VAR                                                 !6
         37        DO_FCALL                                      0  $28     
         38        ASSIGN                                                   !7, $28
   35    39        INIT_FCALL                                               'base64url_encode'
         40        SEND_VAR                                                 !7
         41        DO_FCALL                                      0  $30     
         42        ASSIGN                                                   !8, $30
   36    43        INIT_FCALL                                               'print_r'
         44        CONCAT                                           ~32     '+++++New+cipher+text%3A+', !8
         45        CONCAT                                           ~33     ~32, '%0A'
         46        SEND_VAL                                                 ~33
         47        DO_ICALL                                                 
   37    48        INIT_FCALL                                               'print_r'
         49        CONCAT                                           ~35     'Original+cipher+text%3A+', !0
         50        CONCAT                                           ~36     ~35, !5
         51        CONCAT                                           ~37     ~36, '%0A'
         52        SEND_VAL                                                 ~37
         53        DO_ICALL                                                 
   40    54        CONCAT                                           ~39     !3, !2
         55        ASSIGN                                                   !6, ~39
   41    56        INIT_FCALL                                               'encryptcode'
         57        SEND_VAR                                                 !6
         58        DO_FCALL                                      0  $41     
         59        ASSIGN                                                   !7, $41
   42    60        INIT_FCALL                                               'base64url_encode'
         61        SEND_VAR                                                 !7
         62        DO_FCALL                                      0  $43     
         63        ASSIGN                                                   !8, $43
   43    64        INIT_FCALL                                               'print_r'
         65        CONCAT                                           ~45     '+++++New+cipher+text%3A+', !8
         66        CONCAT                                           ~46     ~45, '%0A'
         67        SEND_VAL                                                 ~46
         68        DO_ICALL                                                 
   44    69        INIT_FCALL                                               'print_r'
         70        CONCAT                                           ~48     'Original+cipher+text%3A+', !5
         71        CONCAT                                           ~49     ~48, !0
         72        CONCAT                                           ~50     ~49, '%0A'
         73        SEND_VAL                                                 ~50
         74        DO_ICALL                                                 
         75      > RETURN                                                   1

Function base64url_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nv7UJ
function name:  base64url_encode
number of ops:  15
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'rtrim'
          2        INIT_FCALL                                               'strtr'
          3        INIT_FCALL                                               'base64_encode'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        SEND_VAL                                                 '%2B%2F'
          8        SEND_VAL                                                 '-_'
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        SEND_VAL                                                 '%3D'
         12        DO_ICALL                                         $3      
         13      > RETURN                                                   $3
    5    14*     > RETURN                                                   null

End of function base64url_encode

Function base64url_decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nv7UJ
function name:  base64url_decode
number of ops:  19
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'base64_decode'
          2        INIT_FCALL                                               'str_pad'
          3        INIT_FCALL                                               'strtr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 '-_'
          6        SEND_VAL                                                 '%2B%2F'
          7        DO_ICALL                                         $1      
          8        SEND_VAR                                                 $1
          9        STRLEN                                           ~2      !0
         10        MOD                                              ~3      ~2, 4
         11        SEND_VAL                                                 ~3
         12        SEND_VAL                                                 '%3D'
         13        SEND_VAL                                                 1
         14        DO_ICALL                                         $4      
         15        SEND_VAR                                                 $4
         16        DO_ICALL                                         $5      
         17      > RETURN                                                   $5
    9    18*     > RETURN                                                   null

End of function base64url_decode

Function encryptcode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nv7UJ
function name:  encryptCode
number of ops:  11
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
          2        FETCH_CONSTANT                                   ~1      'MCRYPT_DES'
          3        SEND_VAL_EX                                              ~1
          4        SEND_VAL_EX                                              '12345678'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              'cbc'
          7        SEND_VAL_EX                                              '87654321'
          8        DO_FCALL                                      0  $2      
          9      > RETURN                                                   $2
   13    10*     > RETURN                                                   null

End of function encryptcode

Function decryptcode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nv7UJ
function name:  decryptCode
number of ops:  11
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
          2        FETCH_CONSTANT                                   ~1      'MCRYPT_DES'
          3        SEND_VAL_EX                                              ~1
          4        SEND_VAL_EX                                              '12345678'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              'cbc'
          7        SEND_VAL_EX                                              '87654321'
          8        DO_FCALL                                      0  $2      
          9      > RETURN                                                   $2
   17    10*     > RETURN                                                   null

End of function decryptcode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.62 ms | 1457 KiB | 27 Q