3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set the method $method = 'AES-128-CBC'; // Set the encryption key $encryption_key = 'myencryptionkey'; // Generet a random initialisation vector $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method)); // Define the date to be encrypted $data = "Encrypt me, please!"; var_dump("Before encryption: $data"); // Encrypt the data $encrypted = openssl_encrypt($data, $method, $encryption_key, 0, $iv); var_dump("Encrypted: ${encrypted}"); // Append the vector at the end of the encrypted string $encrypted = $encrypted . ':' . $iv; var_dump($encrypted); // Explode the string using the `:` separator. $parts = explode(':', $encrypted); // Decrypt the data $decrypted = openssl_decrypt($parts[0], $method, $encryption_key, 0, $parts[1]); var_dump("Decrypted: ${decrypted}");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ookl5
function name:  (null)
number of ops:  57
compiled vars:  !0 = $method, !1 = $encryption_key, !2 = $iv, !3 = $data, !4 = $encrypted, !5 = $parts, !6 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, 'AES-128-CBC'
    8     1        ASSIGN                                                   !1, 'myencryptionkey'
   11     2        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          3        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $9      
          6        SEND_VAR_NO_REF_EX                                       $9
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !2, $10
   14     9        ASSIGN                                                   !3, 'Encrypt+me%2C+please%21'
   16    10        INIT_FCALL                                               'var_dump'
         11        NOP                                                      
         12        FAST_CONCAT                                      ~13     'Before+encryption%3A+', !3
         13        SEND_VAL                                                 ~13
         14        DO_ICALL                                                 
   19    15        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         16        SEND_VAR_EX                                              !3
         17        SEND_VAR_EX                                              !0
         18        SEND_VAR_EX                                              !1
         19        SEND_VAL_EX                                              0
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $15     
         22        ASSIGN                                                   !4, $15
   21    23        INIT_FCALL                                               'var_dump'
         24        NOP                                                      
         25        FAST_CONCAT                                      ~17     'Encrypted%3A+', !4
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                                 
   24    28        CONCAT                                           ~19     !4, '%3A'
         29        CONCAT                                           ~20     ~19, !2
         30        ASSIGN                                                   !4, ~20
   25    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                                 
   28    34        INIT_FCALL                                               'explode'
         35        SEND_VAL                                                 '%3A'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $23     
         38        ASSIGN                                                   !5, $23
   31    39        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
         40        CHECK_FUNC_ARG                                           
         41        FETCH_DIM_FUNC_ARG                               $25     !5, 0
         42        SEND_FUNC_ARG                                            $25
         43        SEND_VAR_EX                                              !0
         44        SEND_VAR_EX                                              !1
         45        SEND_VAL_EX                                              0
         46        CHECK_FUNC_ARG                                           
         47        FETCH_DIM_FUNC_ARG                               $26     !5, 1
         48        SEND_FUNC_ARG                                            $26
         49        DO_FCALL                                      0  $27     
         50        ASSIGN                                                   !6, $27
   33    51        INIT_FCALL                                               'var_dump'
         52        NOP                                                      
         53        FAST_CONCAT                                      ~29     'Decrypted%3A+', !6
         54        SEND_VAL                                                 ~29
         55        DO_ICALL                                                 
         56      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.3 ms | 1443 KiB | 15 Q