3v4l.org

run code in 500+ 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:  23
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                                                   'base64_encode'
          3        INIT_FCALL_BY_NAME                                           'openssl_encrypt'
          4        SEND_VAR_EX                                                  !0
          5        SEND_VAL_EX                                                  'AES-256-CBC'
          6        SEND_VAR_EX                                                  !1
          7        SEND_VAL_EX                                                  0
          8        INIT_FCALL_BY_NAME                                           'openssl_random_pseudo_bytes'
          9        INIT_FCALL_BY_NAME                                           'openssl_cipher_iv_length'
         10        SEND_VAL_EX                                                  'AES-256-CBC'
         11        DO_FCALL                                          0  $2      
         12        SEND_VAR_NO_REF_EX                                           $2
         13        DO_FCALL                                          0  $3      
         14        SEND_VAR_NO_REF_EX                                           $3
         15        DO_FCALL                                          0  $4      
         16        SEND_VAR                                                     $4
         17        DO_ICALL                                             $5      
         18        FRAMELESS_ICALL_3                strtr               ~6      $5, '%2B%2F%3D'
         19        OP_DATA                                                      '-_%2C'
         20        FRAMELESS_ICALL_1                trim                ~7      ~6
         21      > RETURN                                                       ~7
    9    22*     > 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:  20
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_BY_NAME                                           'openssl_decrypt'
          3        INIT_FCALL                                                   'base64_decode'
          4        FRAMELESS_ICALL_3                strtr               ~2      !0, '-_%2C'
          5        OP_DATA                                                      '%2B%2F%3D'
          6        SEND_VAL                                                     ~2
          7        DO_ICALL                                             $3      
          8        SEND_VAR_NO_REF_EX                                           $3
          9        SEND_VAL_EX                                                  'AES-256-CBC'
         10        SEND_VAR_EX                                                  !1
         11        SEND_VAL_EX                                                  0
         12        INIT_FCALL_BY_NAME                                           'openssl_cipher_iv_length'
         13        SEND_VAL_EX                                                  'AES-256-CBC'
         14        DO_FCALL                                          0  $4      
         15        SEND_VAR_NO_REF_EX                                           $4
         16        DO_FCALL                                          0  $5      
         17        FRAMELESS_ICALL_1                trim                ~6      $5
         18      > RETURN                                                       ~6
   15    19*     > RETURN                                                       null

End of function decrypt

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
146.16 ms | 2668 KiB | 18 Q