3v4l.org

run code in 300+ PHP versions simultaneously
<?php # --- 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 = 'ICS2015'; # show key size use either 16, 24 or 32 byte keys for AES-128, 192 # and 256 respectively $key_size = strlen($key); echo "Key size: " . $key_size . "\n"; $plaintext = "boy10@naver.com"; # 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, $plaintext, 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"; # === WARNING === # Resulting cipher text has no integrity or authenticity added # and is not protected against padding oracle attacks. # --- DECRYPTION --- $ciphertext_dec = base64_decode($ciphertext_base64); # retrieves the IV, iv_size should be created using mcrypt_get_iv_size() $iv_dec = substr($ciphertext_dec, 0, $iv_size); # retrieves the cipher text (everything except the $iv_size in the front) $ciphertext_dec = substr($ciphertext_dec, $iv_size); # may remove 00h valued characters from end of plain text $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec); echo $plaintext_dec . "\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ho0jH
function name:  (null)
number of ops:  66
compiled vars:  !0 = $key, !1 = $key_size, !2 = $plaintext, !3 = $iv_size, !4 = $iv, !5 = $ciphertext, !6 = $ciphertext_base64, !7 = $ciphertext_dec, !8 = $iv_dec, !9 = $plaintext_dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, 'ICS2015'
   11     1        STRLEN                                           ~11     !0
          2        ASSIGN                                                   !1, ~11
   12     3        CONCAT                                           ~13     'Key+size%3A+', !1
          4        CONCAT                                           ~14     ~13, '%0A'
          5        ECHO                                                     ~14
   14     6        ASSIGN                                                   !2, 'boy10%40naver.com'
   17     7        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          8        FETCH_CONSTANT                                   ~16     'MCRYPT_RIJNDAEL_128'
          9        SEND_VAL_EX                                              ~16
         10        FETCH_CONSTANT                                   ~17     'MCRYPT_MODE_CBC'
         11        SEND_VAL_EX                                              ~17
         12        DO_FCALL                                      0  $18     
         13        ASSIGN                                                   !3, $18
   18    14        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         15        SEND_VAR_EX                                              !3
         16        FETCH_CONSTANT                                   ~20     'MCRYPT_RAND'
         17        SEND_VAL_EX                                              ~20
         18        DO_FCALL                                      0  $21     
         19        ASSIGN                                                   !4, $21
   24    20        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         21        FETCH_CONSTANT                                   ~23     'MCRYPT_RIJNDAEL_128'
         22        SEND_VAL_EX                                              ~23
         23        SEND_VAR_EX                                              !0
         24        SEND_VAR_EX                                              !2
   25    25        FETCH_CONSTANT                                   ~24     'MCRYPT_MODE_CBC'
         26        SEND_VAL_EX                                              ~24
   24    27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0  $25     
         29        ASSIGN                                                   !5, $25
   28    30        CONCAT                                           ~27     !4, !5
         31        ASSIGN                                                   !5, ~27
   31    32        INIT_FCALL                                               'base64_encode'
         33        SEND_VAR                                                 !5
         34        DO_ICALL                                         $29     
         35        ASSIGN                                                   !6, $29
   33    36        CONCAT                                           ~31     !6, '%0A'
         37        ECHO                                                     ~31
   42    38        INIT_FCALL                                               'base64_decode'
         39        SEND_VAR                                                 !6
         40        DO_ICALL                                         $32     
         41        ASSIGN                                                   !7, $32
   45    42        INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !7
         44        SEND_VAL                                                 0
         45        SEND_VAR                                                 !3
         46        DO_ICALL                                         $34     
         47        ASSIGN                                                   !8, $34
   48    48        INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !7
         50        SEND_VAR                                                 !3
         51        DO_ICALL                                         $36     
         52        ASSIGN                                                   !7, $36
   51    53        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
         54        FETCH_CONSTANT                                   ~38     'MCRYPT_RIJNDAEL_128'
         55        SEND_VAL_EX                                              ~38
         56        SEND_VAR_EX                                              !0
         57        SEND_VAR_EX                                              !7
   52    58        FETCH_CONSTANT                                   ~39     'MCRYPT_MODE_CBC'
         59        SEND_VAL_EX                                              ~39
   51    60        SEND_VAR_EX                                              !8
         61        DO_FCALL                                      0  $40     
         62        ASSIGN                                                   !9, $40
   54    63        CONCAT                                           ~42     !9, '%0A'
         64        ECHO                                                     ~42
   55    65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
212.38 ms | 1400 KiB | 19 Q