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

Function pkcs7_pad:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oBPR0
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:
163.36 ms | 1400 KiB | 23 Q