3v4l.org

run code in 300+ PHP versions simultaneously
<?php $partner_key = 1; $string = 'test_string'; # --- ENCRYPTION --- # the key should be random binary, use scrypt, bcrypt or PBKDF2 to # convert a string into a key # key is specified using hexadecimal $key = pack('H*', bin2hex($partner_key)); # show key size use either 16, 24 or 32 byte keys for AES-128, 192 # and 256 respectively $key_size = strlen($key); # create a random IV to use with CBC encoding $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); # creates a cipher text compatible with AES (Rijndael block size = 128) # to keep the text confidential # only suitable for encoded input that never ends with value 00h # (because of default zero padding) $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string, MCRYPT_MODE_CBC, $iv); # prepend the IV for it to be available for decryption $ciphertext = $iv . $ciphertext; # encode the resulting cipher text so it can be represented by a string $ciphertext_base64 = base64_encode($ciphertext); //echo $ciphertext_base64 . "\n"; echo $ciphertext_base64;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEfeu
function name:  (null)
number of ops:  43
compiled vars:  !0 = $partner_key, !1 = $string, !2 = $key, !3 = $key_size, !4 = $iv_size, !5 = $iv, !6 = $ciphertext, !7 = $ciphertext_base64
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
    4     1        ASSIGN                                                   !1, 'test_string'
    9     2        INIT_FCALL                                               'pack'
          3        SEND_VAL                                                 'H%2A'
          4        INIT_FCALL                                               'bin2hex'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $10     
          7        SEND_VAR                                                 $10
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !2, $11
   13    10        STRLEN                                           ~13     !2
         11        ASSIGN                                                   !3, ~13
   16    12        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
         13        FETCH_CONSTANT                                   ~15     'MCRYPT_RIJNDAEL_128'
         14        SEND_VAL_EX                                              ~15
         15        FETCH_CONSTANT                                   ~16     'MCRYPT_MODE_CBC'
         16        SEND_VAL_EX                                              ~16
         17        DO_FCALL                                      0  $17     
         18        ASSIGN                                                   !4, $17
   17    19        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         20        SEND_VAR_EX                                              !4
         21        FETCH_CONSTANT                                   ~19     'MCRYPT_RAND'
         22        SEND_VAL_EX                                              ~19
         23        DO_FCALL                                      0  $20     
         24        ASSIGN                                                   !5, $20
   23    25        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         26        FETCH_CONSTANT                                   ~22     'MCRYPT_RIJNDAEL_128'
         27        SEND_VAL_EX                                              ~22
         28        SEND_VAR_EX                                              !2
         29        SEND_VAR_EX                                              !1
         30        FETCH_CONSTANT                                   ~23     'MCRYPT_MODE_CBC'
         31        SEND_VAL_EX                                              ~23
         32        SEND_VAR_EX                                              !5
         33        DO_FCALL                                      0  $24     
         34        ASSIGN                                                   !6, $24
   26    35        CONCAT                                           ~26     !5, !6
         36        ASSIGN                                                   !6, ~26
   29    37        INIT_FCALL                                               'base64_encode'
         38        SEND_VAR                                                 !6
         39        DO_ICALL                                         $28     
         40        ASSIGN                                                   !7, $28
   32    41        ECHO                                                     !7
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.3 ms | 1400 KiB | 19 Q