3v4l.org

run code in 500+ PHP versions simultaneously
<?php $message = 'test'; $key = openssl_random_pseudo_bytes(16); $iv = openssl_random_pseudo_bytes(16); $cipher = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $key, $message, MCRYPT_MODE_CBC, $iv ); $plain = openssl_decrypt( $cipher, 'aes-128-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv ); //try to detect null padding if (mb_strlen($iv, '8bit') % mb_strlen($plain, '8bit') == 0) { preg_match_all('#([\0]+)$#', $plain, $matches); if (mb_strlen($matches[1][0], '8bit') > 1) { $plain = rtrim($plain, "\0"); trigger_error('Detected and stripped null padding. Please double-check results!'); } } var_dump( $message, bin2hex($cipher), $plain, mb_strlen($message, '8bit'), mb_strlen($plain, '8bit'), $message === $plain );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 62
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 62
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 62
filename:       /in/kYAXn
function name:  (null)
number of ops:  83
compiled vars:  !0 = $message, !1 = $key, !2 = $iv, !3 = $cipher, !4 = $plain, !5 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'test'
    3     1        INIT_FCALL_BY_NAME                                           'openssl_random_pseudo_bytes'
          2        SEND_VAL_EX                                                  16
          3        DO_FCALL                                          0  $7      
          4        ASSIGN                                                       !1, $7
    4     5        INIT_FCALL_BY_NAME                                           'openssl_random_pseudo_bytes'
          6        SEND_VAL_EX                                                  16
          7        DO_FCALL                                          0  $9      
          8        ASSIGN                                                       !2, $9
    6     9        INIT_FCALL_BY_NAME                                           'mcrypt_encrypt'
    7    10        FETCH_CONSTANT                                       ~11     'MCRYPT_RIJNDAEL_128'
         11        SEND_VAL_EX                                                  ~11
         12        SEND_VAR_EX                                                  !1
         13        SEND_VAR_EX                                                  !0
   10    14        FETCH_CONSTANT                                       ~12     'MCRYPT_MODE_CBC'
         15        SEND_VAL_EX                                                  ~12
    7    16        SEND_VAR_EX                                                  !2
    6    17        DO_FCALL                                          0  $13     
         18        ASSIGN                                                       !3, $13
   14    19        INIT_FCALL_BY_NAME                                           'openssl_decrypt'
   15    20        SEND_VAR_EX                                                  !3
   16    21        SEND_VAL_EX                                                  'aes-128-cbc'
   15    22        SEND_VAR_EX                                                  !1
   18    23        FETCH_CONSTANT                                       ~15     'OPENSSL_RAW_DATA'
         24        FETCH_CONSTANT                                       ~16     'OPENSSL_NO_PADDING'
         25        BW_OR                                                ~17     ~15, ~16
         26        SEND_VAL_EX                                                  ~17
   15    27        SEND_VAR_EX                                                  !2
   14    28        DO_FCALL                                          0  $18     
         29        ASSIGN                                                       !4, $18
   23    30        INIT_FCALL                                                   'mb_strlen'
         31        SEND_VAR                                                     !2
         32        SEND_VAL                                                     '8bit'
         33        DO_ICALL                                             $20     
         34        INIT_FCALL                                                   'mb_strlen'
         35        SEND_VAR                                                     !4
         36        SEND_VAL                                                     '8bit'
         37        DO_ICALL                                             $21     
         38        MOD                                                  ~22     $20, $21
         39        IS_EQUAL                                                     ~22, 0
         40      > JMPZ                                                         ~23, ->62
   24    41    >   INIT_FCALL                                                   'preg_match_all'
         42        SEND_VAL                                                     '%23%28%5B%5C0%5D%2B%29%24%23'
         43        SEND_VAR                                                     !4
         44        SEND_REF                                                     !5
         45        DO_ICALL                                                     
   25    46        INIT_FCALL                                                   'mb_strlen'
         47        FETCH_DIM_R                                          ~25     !5, 1
         48        FETCH_DIM_R                                          ~26     ~25, 0
         49        SEND_VAL                                                     ~26
         50        SEND_VAL                                                     '8bit'
         51        DO_ICALL                                             $27     
         52        IS_SMALLER                                                   1, $27
         53      > JMPZ                                                         ~28, ->62
   26    54    >   INIT_FCALL                                                   'rtrim'
         55        SEND_VAR                                                     !4
         56        SEND_VAL                                                     '%00'
         57        DO_ICALL                                             $29     
         58        ASSIGN                                                       !4, $29
   27    59        INIT_FCALL                                                   'trigger_error'
         60        SEND_VAL                                                     'Detected+and+stripped+null+padding.+Please+double-check+results%21'
         61        DO_ICALL                                                     
   33    62    >   INIT_FCALL                                                   'var_dump'
   34    63        SEND_VAR                                                     !0
   35    64        INIT_FCALL                                                   'bin2hex'
         65        SEND_VAR                                                     !3
         66        DO_ICALL                                             $32     
         67        SEND_VAR                                                     $32
   36    68        SEND_VAR                                                     !4
   37    69        INIT_FCALL                                                   'mb_strlen'
         70        SEND_VAR                                                     !0
         71        SEND_VAL                                                     '8bit'
         72        DO_ICALL                                             $33     
         73        SEND_VAR                                                     $33
   38    74        INIT_FCALL                                                   'mb_strlen'
         75        SEND_VAR                                                     !4
         76        SEND_VAL                                                     '8bit'
         77        DO_ICALL                                             $34     
         78        SEND_VAR                                                     $34
   39    79        IS_IDENTICAL                                         ~35     !0, !4
         80        SEND_VAL                                                     ~35
   33    81        DO_ICALL                                                     
   40    82      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.28 ms | 2998 KiB | 19 Q