3v4l.org

run code in 300+ PHP versions simultaneously
<?php $this->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($this->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"; return $ciphertext_base64;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/62q4O
function name:  (null)
number of ops:  47
compiled vars:  !0 = $string, !1 = $key, !2 = $key_size, !3 = $iv_size, !4 = $iv, !5 = $ciphertext, !6 = $ciphertext_base64
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_THIS                                       $7      
          1        ASSIGN_OBJ                                               $7, 'partner_key'
          2        OP_DATA                                                  1
    4     3        ASSIGN                                                   !0, 'test_string'
    9     4        INIT_FCALL                                               'pack'
          5        SEND_VAL                                                 'H%2A'
          6        INIT_FCALL                                               'bin2hex'
          7        FETCH_THIS                                       $10     
          8        FETCH_OBJ_R                                      ~11     $10, 'partner_key'
          9        SEND_VAL                                                 ~11
         10        DO_ICALL                                         $12     
         11        SEND_VAR                                                 $12
         12        DO_ICALL                                         $13     
         13        ASSIGN                                                   !1, $13
   13    14        STRLEN                                           ~15     !1
         15        ASSIGN                                                   !2, ~15
   16    16        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
         17        FETCH_CONSTANT                                   ~17     'MCRYPT_RIJNDAEL_128'
         18        SEND_VAL_EX                                              ~17
         19        FETCH_CONSTANT                                   ~18     'MCRYPT_MODE_CBC'
         20        SEND_VAL_EX                                              ~18
         21        DO_FCALL                                      0  $19     
         22        ASSIGN                                                   !3, $19
   17    23        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         24        SEND_VAR_EX                                              !3
         25        FETCH_CONSTANT                                   ~21     'MCRYPT_RAND'
         26        SEND_VAL_EX                                              ~21
         27        DO_FCALL                                      0  $22     
         28        ASSIGN                                                   !4, $22
   23    29        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         30        FETCH_CONSTANT                                   ~24     'MCRYPT_RIJNDAEL_128'
         31        SEND_VAL_EX                                              ~24
         32        SEND_VAR_EX                                              !1
         33        SEND_VAR_EX                                              !0
         34        FETCH_CONSTANT                                   ~25     'MCRYPT_MODE_CBC'
         35        SEND_VAL_EX                                              ~25
         36        SEND_VAR_EX                                              !4
         37        DO_FCALL                                      0  $26     
         38        ASSIGN                                                   !5, $26
   26    39        CONCAT                                           ~28     !4, !5
         40        ASSIGN                                                   !5, ~28
   29    41        INIT_FCALL                                               'base64_encode'
         42        SEND_VAR                                                 !5
         43        DO_ICALL                                         $30     
         44        ASSIGN                                                   !6, $30
   32    45      > RETURN                                                   !6
         46*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.32 ms | 1400 KiB | 19 Q