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"; ?>
Output for 7.0.6 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Key size: 7 Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH:17 Stack trace: #0 {main} thrown in /in/ho0jH on line 17
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Key size: 7 Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH:17 Stack trace: #0 {main} thrown in /in/ho0jH on line 17
Process exited with code 255.
Output for 7.0.5
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 eo90e58BIt+0bPdbNoyMtA== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.4
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 I536Pjd8fZJit5mJahP4mg== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.3
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 FXHuCHGC+L8zN4tSAG1LOQ== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.2
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 Etm1NAK6ZD98vaphPoJg5w== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.1
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 a+D6kiJ15RPq+MhAefNcfg== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 7.0.0
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 Uu8GHBvRAFPqA9XVMZZ1fQ== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.5.35, 5.6.21 - 5.6.28
Key size: 7 Fatal error: Call to undefined function mcrypt_get_iv_size() in /in/ho0jH on line 17
Process exited with code 255.
Output for 5.6.20
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 yKQK2pZVFzIQOBvrrxDaqg== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.19
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 8AJpiVhUEkTgDtLUA+F9cA== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.18
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 vXt5ZpIJnp2YIhsXtwgnCg== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.17
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 1XtnU47eiIR7Pq+LXNfZUA== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.16
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 ruH5xFevuZ671RutrSQdVQ== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.15
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 8O6Gk/L8Z0Se1/QySI8DLw== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.14
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 gz1CJWumWvbmV0iGq00dAg== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.13
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 yKHCw2oYHiBivnLOnHPaZQ== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.12
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 QoYZ1PTcK3wcEQUdSLUUKw== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.11
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 haa2Bn/L3e3Sckc628/mYA== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.10
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 Ev55Yt1wsGsD8AUs/jqGSw== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.9
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 4HoLScfZSYQjxHfh5ROHwQ== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.6.8
Key size: 7 Warning: mcrypt_encrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 25 GKRYZSZWcFosJ7wyAlwGyA== Warning: mcrypt_decrypt(): Key of size 7 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/ho0jH on line 52
Output for 5.5.34
Key size: 7 TLcgsa9wiLD9DtEe8Ow031SQE0O1dnZLWDCsKDhrosg= boy10@naver.com
Output for 5.5.33
Key size: 7 AdeMcvRdQHAPJNcg3IYBEOzWCdqxoR/vuBZSgRrxMFo= boy10@naver.com
Output for 5.5.32
Key size: 7 2x9qfYWMazutXZUwPYsjD0JOFh7zJchGdN3eO61VtFU= boy10@naver.com
Output for 5.5.31
Key size: 7 btpfhL14jpIM3+PB93Ca/i0rX3+2wjyXpPtIDoNaAxc= boy10@naver.com
Output for 5.5.30
Key size: 7 0mF7v2PSWne+r4p6WyxFZ+6ofWyAr0cwU4pldPzGeFo= boy10@naver.com
Output for 5.5.29
Key size: 7 6PATDKi20Eh9omM9RqVmwlmVq+x/nh5xaUXd1dcTun0= boy10@naver.com
Output for 5.5.28
Key size: 7 TD32Y81nU/ZQk9jUSlzl3lLXOok6idmmGWTzA/fzLws= boy10@naver.com
Output for 5.5.27
Key size: 7 Lo6X8BGrx5OqJ1aQRpkpkhFQPlgwMBfNAz6Nauucolk= boy10@naver.com
Output for 5.5.26
Key size: 7 8by83l9ehhnbayM4RMj3CzDRPHGC+enZxYGrovNSQfY= boy10@naver.com
Output for 5.5.25
Key size: 7 ZwRMm8Oi0yXY2viMs8seRJY65Se2Hc3mkHt167I0Oxg= boy10@naver.com
Output for 5.5.24
Key size: 7 6uQuErydKk+rahwGKS59cWZ8Ti/Gh/hbVIU7sY59mnY= boy10@naver.com

preferences:
185.19 ms | 401 KiB | 198 Q