3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = 'This text will encrypt using openssl!'; $secretKey = 'mykey'; function encrypt($data, $secretKey) { return trim(strtr(base64_encode(openssl_encrypt($data, 'AES-256-CBC', $secretKey, 0, openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC')))),'+/=', '-_,')); } $encrypted = encrypt($data, $secretKey); function decrypt($encrypted, $secretKey) { return trim(openssl_decrypt(base64_decode(strtr($encrypted,'-_,', '+/=')),'AES-256-CBC', $secretKey, 0, openssl_cipher_iv_length('AES-256-CBC'))); } $decrypted = decrypt($encrypted, $secretKey); var_dump('Encrypted: ' . $encrypted); var_dump('Decrypted: ' . $decrypted); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qlkqg
function name:  (null)
number of ops:  21
compiled vars:  !0 = $data, !1 = $secretKey, !2 = $encrypted, !3 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+text+will+encrypt+using+openssl%21'
    4     1        ASSIGN                                                   !1, 'mykey'
   10     2        INIT_FCALL                                               'encrypt'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !2, $6
   16     7        INIT_FCALL                                               'decrypt'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $8      
         11        ASSIGN                                                   !3, $8
   18    12        INIT_FCALL                                               'var_dump'
         13        CONCAT                                           ~10     'Encrypted%3A+', !2
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                                 
   19    16        INIT_FCALL                                               'var_dump'
         17        CONCAT                                           ~12     'Decrypted%3A+', !3
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                                 
   20    20      > RETURN                                                   1

Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qlkqg
function name:  encrypt
number of ops:  28
compiled vars:  !0 = $data, !1 = $secretKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'trim'
          3        INIT_FCALL                                               'strtr'
          4        INIT_FCALL                                               'base64_encode'
          5        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              'AES-256-CBC'
          8        SEND_VAR_EX                                              !1
          9        SEND_VAL_EX                                              0
         10        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
         11        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
         12        SEND_VAL_EX                                              'AES-256-CBC'
         13        DO_FCALL                                      0  $2      
         14        SEND_VAR_NO_REF_EX                                       $2
         15        DO_FCALL                                      0  $3      
         16        SEND_VAR_NO_REF_EX                                       $3
         17        DO_FCALL                                      0  $4      
         18        SEND_VAR                                                 $4
         19        DO_ICALL                                         $5      
         20        SEND_VAR                                                 $5
         21        SEND_VAL                                                 '%2B%2F%3D'
         22        SEND_VAL                                                 '-_%2C'
         23        DO_ICALL                                         $6      
         24        SEND_VAR                                                 $6
         25        DO_ICALL                                         $7      
         26      > RETURN                                                   $7
    9    27*     > RETURN                                                   null

End of function encrypt

Function decrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qlkqg
function name:  decrypt
number of ops:  25
compiled vars:  !0 = $encrypted, !1 = $secretKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'trim'
          3        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
          4        INIT_FCALL                                               'base64_decode'
          5        INIT_FCALL                                               'strtr'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 '-_%2C'
          8        SEND_VAL                                                 '%2B%2F%3D'
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                         $3      
         12        SEND_VAR_NO_REF_EX                                       $3
         13        SEND_VAL_EX                                              'AES-256-CBC'
         14        SEND_VAR_EX                                              !1
         15        SEND_VAL_EX                                              0
         16        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
         17        SEND_VAL_EX                                              'AES-256-CBC'
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR_NO_REF_EX                                       $4
         20        DO_FCALL                                      0  $5      
         21        SEND_VAR                                                 $5
         22        DO_ICALL                                         $6      
         23      > RETURN                                                   $6
   15    24*     > RETURN                                                   null

End of function decrypt

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
211.87 ms | 1394 KiB | 25 Q