3v4l.org

run code in 300+ PHP versions simultaneously
<?php $key = 'password to (en/de)crypt'; $string = ' string to be encrypted '; // note the spaces $iv = mcrypt_create_iv( mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM ); $encrypted = base64_encode( $iv . mcrypt_encrypt( MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), $string, MCRYPT_MODE_CBC, $iv ) ); $data = base64_decode($encrypted); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); $decrypted = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv ), "\0" ); echo 'Encrypted:' . "\n"; var_dump($encrypted); echo "\n"; echo 'Decrypted:' . "\n"; var_dump($decrypted);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CJfSn
function name:  (null)
number of ops:  88
compiled vars:  !0 = $key, !1 = $string, !2 = $iv, !3 = $encrypted, !4 = $data, !5 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'password+to+%28en%2Fde%29crypt'
    5     1        ASSIGN                                                   !1, '+string+to+be+encrypted+'
    8     2        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
    9     3        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          4        FETCH_CONSTANT                                   ~8      'MCRYPT_RIJNDAEL_128'
          5        SEND_VAL_EX                                              ~8
          6        FETCH_CONSTANT                                   ~9      'MCRYPT_MODE_CBC'
          7        SEND_VAL_EX                                              ~9
          8        DO_FCALL                                      0  $10     
          9        SEND_VAR_NO_REF_EX                                       $10
   10    10        FETCH_CONSTANT                                   ~11     'MCRYPT_DEV_URANDOM'
         11        SEND_VAL_EX                                              ~11
    8    12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !2, $12
   13    14        INIT_FCALL                                               'base64_encode'
   15    15        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
   16    16        FETCH_CONSTANT                                   ~14     'MCRYPT_RIJNDAEL_128'
         17        SEND_VAL_EX                                              ~14
   17    18        INIT_FCALL                                               'hash'
         19        SEND_VAL                                                 'sha256'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $15     
         23        SEND_VAR_NO_REF_EX                                       $15
   16    24        SEND_VAR_EX                                              !1
   19    25        FETCH_CONSTANT                                   ~16     'MCRYPT_MODE_CBC'
         26        SEND_VAL_EX                                              ~16
   16    27        SEND_VAR_EX                                              !2
   15    28        DO_FCALL                                      0  $17     
   16    29        CONCAT                                           ~18     !2, $17
         30        SEND_VAL                                                 ~18
   13    31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !3, $19
   25    33        INIT_FCALL                                               'base64_decode'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !4, $21
   26    37        INIT_FCALL                                               'substr'
         38        SEND_VAR                                                 !4
         39        SEND_VAL                                                 0
         40        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
         41        FETCH_CONSTANT                                   ~23     'MCRYPT_RIJNDAEL_128'
         42        SEND_VAL_EX                                              ~23
         43        FETCH_CONSTANT                                   ~24     'MCRYPT_MODE_CBC'
         44        SEND_VAL_EX                                              ~24
         45        DO_FCALL                                      0  $25     
         46        SEND_VAR                                                 $25
         47        DO_ICALL                                         $26     
         48        ASSIGN                                                   !2, $26
   28    49        INIT_FCALL                                               'rtrim'
   29    50        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
   30    51        FETCH_CONSTANT                                   ~28     'MCRYPT_RIJNDAEL_128'
         52        SEND_VAL_EX                                              ~28
   31    53        INIT_FCALL                                               'hash'
         54        SEND_VAL                                                 'sha256'
         55        SEND_VAR                                                 !0
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $29     
         58        SEND_VAR_NO_REF_EX                                       $29
   32    59        INIT_FCALL                                               'substr'
         60        SEND_VAR                                                 !4
         61        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
         62        FETCH_CONSTANT                                   ~30     'MCRYPT_RIJNDAEL_128'
         63        SEND_VAL_EX                                              ~30
         64        FETCH_CONSTANT                                   ~31     'MCRYPT_MODE_CBC'
         65        SEND_VAL_EX                                              ~31
         66        DO_FCALL                                      0  $32     
         67        SEND_VAR                                                 $32
         68        DO_ICALL                                         $33     
         69        SEND_VAR_NO_REF_EX                                       $33
   33    70        FETCH_CONSTANT                                   ~34     'MCRYPT_MODE_CBC'
         71        SEND_VAL_EX                                              ~34
   30    72        SEND_VAR_EX                                              !2
   29    73        DO_FCALL                                      0  $35     
   30    74        SEND_VAR                                                 $35
   36    75        SEND_VAL                                                 '%00'
   28    76        DO_ICALL                                         $36     
         77        ASSIGN                                                   !5, $36
   41    78        ECHO                                                     'Encrypted%3A%0A'
   42    79        INIT_FCALL                                               'var_dump'
         80        SEND_VAR                                                 !3
         81        DO_ICALL                                                 
   44    82        ECHO                                                     '%0A'
   46    83        ECHO                                                     'Decrypted%3A%0A'
   47    84        INIT_FCALL                                               'var_dump'
         85        SEND_VAR                                                 !5
         86        DO_ICALL                                                 
         87      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.79 ms | 1470 KiB | 19 Q