3v4l.org

run code in 300+ 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), 'ctr', $iv ); $plain = openssl_decrypt( $cipher, 'aes-128-ctr', $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/DEn2R
function name:  (null)
number of ops:  51
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        SEND_VAL_EX                                              'ctr'
   15    18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0  $12     
   14    20        ASSIGN                                                   !3, $12
   22    21        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
   23    22        SEND_VAR_EX                                              !3
   24    23        SEND_VAL_EX                                              'aes-128-ctr'
   23    24        SEND_VAR_EX                                              !1
   26    25        FETCH_CONSTANT                                   ~14     'OPENSSL_RAW_DATA'
         26        SEND_VAL_EX                                              ~14
   23    27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0  $15     
   22    29        ASSIGN                                                   !4, $15
   30    30        INIT_FCALL                                               'var_dump'
   31    31        SEND_VAR                                                 !0
   32    32        INIT_FCALL                                               'bin2hex'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $17     
         35        SEND_VAR                                                 $17
   33    36        SEND_VAR                                                 !4
   34    37        INIT_FCALL                                               'mb_strlen'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 '8bit'
         40        DO_ICALL                                         $18     
         41        SEND_VAR                                                 $18
   35    42        INIT_FCALL                                               'mb_strlen'
         43        SEND_VAR                                                 !4
         44        SEND_VAL                                                 '8bit'
         45        DO_ICALL                                         $19     
         46        SEND_VAR                                                 $19
   36    47        IS_IDENTICAL                                     ~20     !0, !4
         48        SEND_VAL                                                 ~20
         49        DO_ICALL                                                 
   37    50      > RETURN                                                   1

Function pkcs7_pad:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DEn2R
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.0.0


preferences:
161.43 ms | 1402 KiB | 24 Q