3v4l.org

run code in 300+ PHP versions simultaneously
<?php // DEFINE our cipher define('AES_256_CBC', 'aes-256-cbc'); // Generate a 256-bit encryption key // This should be stored somewhere instead of recreating it each time $encryption_key = openssl_random_pseudo_bytes(32); // Generate an initialization vector // This *MUST* be available for decryption as well $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(AES_256_CBC)); // Create some data to encrypt $data = "Encrypt me, please!"; echo "Before encryption: $data\n"; // Encrypt $data using aes-256-cbc cipher with the given encryption key and // our initialization vector. The 0 gives us the default options, but can // be changed to OPENSSL_RAW_DATA or OPENSSL_ZERO_PADDING $encrypted = openssl_encrypt($data, AES_256_CBC, $encryption_key, 0, $iv); echo "Encrypted: $encrypted\n"; // If we lose the $iv variable, we can't decrypt this, so append it to the // encrypted data with a separator that we know won't exist in base64-encoded // data $encrypted = $encrypted . ':' . $iv; // To decrypt, separate the encrypted data from the initialization vector ($iv) $parts = explode(':', $encrypted); // $parts[0] = encrypted data // $parts[1] = initialization vector $decrypted = openssl_decrypt($parts[0], AES_256_CBC, $encryption_key, 0, $parts[1]); echo "Decrypted: $decrypted\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nos4i
function name:  (null)
number of ops:  60
compiled vars:  !0 = $encryption_key, !1 = $iv, !2 = $data, !3 = $encrypted, !4 = $parts, !5 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'AES_256_CBC'
          2        SEND_VAL                                                 'aes-256-cbc'
          3        DO_ICALL                                                 
    6     4        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          5        SEND_VAL_EX                                              32
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !0, $7
    9     8        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          9        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
         10        FETCH_CONSTANT                                   ~9      'AES_256_CBC'
         11        SEND_VAL_EX                                              ~9
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR_NO_REF_EX                                       $10
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !1, $11
   11    16        ASSIGN                                                   !2, 'Encrypt+me%2C+please%21'
   12    17        ROPE_INIT                                     3  ~15     'Before+encryption%3A+'
         18        ROPE_ADD                                      1  ~15     ~15, !2
         19        ROPE_END                                      2  ~14     ~15, '%0A'
         20        ECHO                                                     ~14
   16    21        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         22        SEND_VAR_EX                                              !2
         23        FETCH_CONSTANT                                   ~17     'AES_256_CBC'
         24        SEND_VAL_EX                                              ~17
         25        SEND_VAR_EX                                              !0
         26        SEND_VAL_EX                                              0
         27        SEND_VAR_EX                                              !1
         28        DO_FCALL                                      0  $18     
         29        ASSIGN                                                   !3, $18
   17    30        ROPE_INIT                                     3  ~21     'Encrypted%3A+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '%0A'
         33        ECHO                                                     ~20
   21    34        CONCAT                                           ~23     !3, '%3A'
         35        CONCAT                                           ~24     ~23, !1
         36        ASSIGN                                                   !3, ~24
   23    37        INIT_FCALL                                               'explode'
         38        SEND_VAL                                                 '%3A'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                         $26     
         41        ASSIGN                                                   !4, $26
   26    42        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
         43        CHECK_FUNC_ARG                                           
         44        FETCH_DIM_FUNC_ARG                               $28     !4, 0
         45        SEND_FUNC_ARG                                            $28
         46        FETCH_CONSTANT                                   ~29     'AES_256_CBC'
         47        SEND_VAL_EX                                              ~29
         48        SEND_VAR_EX                                              !0
         49        SEND_VAL_EX                                              0
         50        CHECK_FUNC_ARG                                           
         51        FETCH_DIM_FUNC_ARG                               $30     !4, 1
         52        SEND_FUNC_ARG                                            $30
         53        DO_FCALL                                      0  $31     
         54        ASSIGN                                                   !5, $31
   27    55        ROPE_INIT                                     3  ~34     'Decrypted%3A+'
         56        ROPE_ADD                                      1  ~34     ~34, !5
         57        ROPE_END                                      2  ~33     ~34, '%0A'
         58        ECHO                                                     ~33
   28    59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.39 ms | 1400 KiB | 17 Q