3v4l.org

run code in 500+ PHP versions simultaneously
<?php function pkcs7_pad($str) { $len = mb_strlen($str, '8bit'); $c = 16 - ($len % 16); $str .= str_repeat(chr($c), $c); return $str; } $message = 'test'; $key = openssl_random_pseudo_bytes(16); $iv = openssl_random_pseudo_bytes(16); $cipher = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $key, pkcs7_pad($message), MCRYPT_MODE_CBC, $iv ); $plain = openssl_decrypt( $cipher, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv ); var_dump( $message, bin2hex($cipher), $plain, mb_strlen($message, '8bit'), mb_strlen($plain, '8bit'), $message === $plain );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bdQe9
function name:  (null)
number of ops:  52
compiled vars:  !0 = $message, !1 = $key, !2 = $iv, !3 = $cipher, !4 = $plain
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                       !0, 'test'
   11     1        INIT_FCALL_BY_NAME                                           'openssl_random_pseudo_bytes'
          2        SEND_VAL_EX                                                  16
          3        DO_FCALL                                          0  $6      
          4        ASSIGN                                                       !1, $6
   12     5        INIT_FCALL_BY_NAME                                           'openssl_random_pseudo_bytes'
          6        SEND_VAL_EX                                                  16
          7        DO_FCALL                                          0  $8      
          8        ASSIGN                                                       !2, $8
   14     9        INIT_FCALL_BY_NAME                                           'mcrypt_encrypt'
   15    10        FETCH_CONSTANT                                       ~10     'MCRYPT_RIJNDAEL_128'
         11        SEND_VAL_EX                                                  ~10
         12        SEND_VAR_EX                                                  !1
   17    13        INIT_FCALL                                                   'pkcs7_pad'
         14        SEND_VAR                                                     !0
         15        DO_FCALL                                          0  $11     
         16        SEND_VAR_NO_REF_EX                                           $11
   18    17        FETCH_CONSTANT                                       ~12     'MCRYPT_MODE_CBC'
         18        SEND_VAL_EX                                                  ~12
   15    19        SEND_VAR_EX                                                  !2
   14    20        DO_FCALL                                          0  $13     
         21        ASSIGN                                                       !3, $13
   22    22        INIT_FCALL_BY_NAME                                           'openssl_decrypt'
   23    23        SEND_VAR_EX                                                  !3
   24    24        SEND_VAL_EX                                                  'aes-128-cbc'
   23    25        SEND_VAR_EX                                                  !1
   26    26        FETCH_CONSTANT                                       ~15     'OPENSSL_RAW_DATA'
         27        SEND_VAL_EX                                                  ~15
   23    28        SEND_VAR_EX                                                  !2
   22    29        DO_FCALL                                          0  $16     
         30        ASSIGN                                                       !4, $16
   30    31        INIT_FCALL                                                   'var_dump'
   31    32        SEND_VAR                                                     !0
   32    33        INIT_FCALL                                                   'bin2hex'
         34        SEND_VAR                                                     !3
         35        DO_ICALL                                             $18     
         36        SEND_VAR                                                     $18
   33    37        SEND_VAR                                                     !4
   34    38        INIT_FCALL                                                   'mb_strlen'
         39        SEND_VAR                                                     !0
         40        SEND_VAL                                                     '8bit'
         41        DO_ICALL                                             $19     
         42        SEND_VAR                                                     $19
   35    43        INIT_FCALL                                                   'mb_strlen'
         44        SEND_VAR                                                     !4
         45        SEND_VAL                                                     '8bit'
         46        DO_ICALL                                             $20     
         47        SEND_VAR                                                     $20
   36    48        IS_IDENTICAL                                         ~21     !0, !4
         49        SEND_VAL                                                     ~21
   30    50        DO_ICALL                                                     
   37    51      > RETURN                                                       1

Function pkcs7_pad:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bdQe9
function name:  pkcs7_pad
number of ops:  19
compiled vars:  !0 = $str, !1 = $len, !2 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'mb_strlen'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     '8bit'
          4        DO_ICALL                                             $3      
          5        ASSIGN                                                       !1, $3
    5     6        MOD                                                  ~5      !1, 16
          7        SUB                                                  ~6      16, ~5
          8        ASSIGN                                                       !2, ~6
    6     9        INIT_FCALL                                                   'str_repeat'
         10        INIT_FCALL                                                   'chr'
         11        SEND_VAR                                                     !2
         12        DO_ICALL                                             $8      
         13        SEND_VAR                                                     $8
         14        SEND_VAR                                                     !2
         15        DO_ICALL                                             $9      
         16        ASSIGN_OP                                         8          !0, $9
    7    17      > RETURN                                                       !0
    8    18*     > RETURN                                                       null

End of function pkcs7_pad

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.01 ms | 2996 KiB | 19 Q