3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; ?>
based on Wh5Pp
Output for 7.0.6 - 7.2.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.3.20 - 5.3.29, 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
Output for 5.4.45
Key size: 7 ZW998g69dwqinFpCFQqWPtKqlOwtzoviO/mvv7kjlWY= boy10@naver.com
Output for 5.4.44
Key size: 7 7IQVwghfdmOShjbCZCLrlV/ucx2eTr0y7aJj0pC2xCQ= boy10@naver.com
Output for 5.4.43
Key size: 7 64hSvP0u3d7LJDzAP4iHLtZTYL7OtA8mD28u4NdpAeE= boy10@naver.com
Output for 5.4.42
Key size: 7 DKqoovnoObDm3Pdfz3Px427ol4WUkAcdnG2hDB5+iEc= boy10@naver.com
Output for 5.4.41
Key size: 7 akwntweUAWqZRKnRwfM9LHizwm+NoJ1G0B7NyKoipgQ= boy10@naver.com
Output for 5.4.40
Key size: 7 lXIypoNwgSXkOAAOzrpFKp4o4sN33Q5CAzPxIy+KMNU= boy10@naver.com
Output for 5.4.39
Key size: 7 xYYyIPf31niSK5SKvZx90VhZgQxIXNWMvYt2lKgYVcc= boy10@naver.com
Output for 5.4.38
Key size: 7 AmL19cNKumxJK73qmw2vXeDsiOnLj15LTmU4Q45rW/Q= boy10@naver.com
Output for 5.4.37
Key size: 7 mkVyymp8q1p0rOvK5Z0o5rzxhU+rdQQFYKVqq0qb+Xk= boy10@naver.com
Output for 5.4.36
Key size: 7 sXMiXsMsX5tQmZbtjQB63UC7ZrJ+DV8Y8PuhndNXqPM= boy10@naver.com
Output for 5.4.35
Key size: 7 U5dQ+5cRqc6gjXCi7RG/xdiwgmTfYzYzBUaaQWqFi00= boy10@naver.com
Output for 5.4.34
Key size: 7 wntOPfBYt2u/ziuI4Qwlz8kZP/wAf8EfI1OIGU13r/E= boy10@naver.com
Output for 5.4.32
Key size: 7 kDTQGPAwsLykqFR1Ln5wj8zhFv3KX0JvT9RzY9RRO10= boy10@naver.com
Output for 5.4.31
Key size: 7 AWQ/0HaJJKsDnkda+BCdvZMueANE4jeDgvJsglb9nFY= boy10@naver.com
Output for 5.4.30
Key size: 7 xT0jLNofEp3tUXmE9o2YSZ+cP8rIEagqEqUxCS4rt0U= boy10@naver.com
Output for 5.4.29
Key size: 7 jzVz9ODPEt7M11jsI0wAwmW291QiNTIDL4cS+XaGoZQ= boy10@naver.com
Output for 5.4.28
Key size: 7 Jx+JQO5dOzMiJjATvX1CTntK/F9GnSw4ZbptSbGdaXs= boy10@naver.com
Output for 5.4.27
Key size: 7 XJJBXZY26U4v0ZtHkvKAZyuKpPC2vLWqoSzcP1gTGt0= boy10@naver.com
Output for 5.4.26
Key size: 7 H1JoJrNVxkP15CmzM1lWYBCQgzYvagZpOHSHCwX+shA= boy10@naver.com
Output for 5.4.25
Key size: 7 bPfmvYmY+ngmgEN2Y/RAikJlgMcFXXlnx0eU9HF7DAk= boy10@naver.com
Output for 5.4.24
Key size: 7 hfvyp2K5zAjWHwmOvEd7mHAAskZ1Nnfv8R8Obg0XJmc= boy10@naver.com
Output for 5.4.23
Key size: 7 4SLukx6Vb/w4lE0VTl/CPsBx8FMgJRoAs/RlfschyXs= boy10@naver.com
Output for 5.4.22
Key size: 7 THHJKqUZJyUNUHGjqp0Ye7w2CGfzloMqWV1AZqtQ7DA= boy10@naver.com
Output for 5.4.21
Key size: 7 TFbJDfcoYbsGffoJgLJxZMFvJ1RJIFJuogJGv2P0otw= boy10@naver.com
Output for 5.4.20
Key size: 7 h4CdULqfcSFKFKI6br9c9Er2uOWMkWLtkEphNk+nMco= boy10@naver.com
Output for 5.4.19
Key size: 7 aauLf0ybjE1dY2xdj/wcJjRmrgyBwp97zykzlOuyC6s= boy10@naver.com
Output for 5.4.18
Key size: 7 wHogIBpBthVDYAe/ty9rgrM8oJlDIaxWIiNQ/exmRio= boy10@naver.com
Output for 5.4.17
Key size: 7 S2fao0yH51lIkYo2z6LUjYSjMPRBY9U3+QSEkmQ2AgE= boy10@naver.com
Output for 5.4.16
Key size: 7 naGdyf3Cz38n4wtOkBS/oAvOFm8D677yxX0H7kNefv8= boy10@naver.com
Output for 5.4.15
Key size: 7 mbmARNNwnGXOZSjsKodFhDzYkpqM1xMkKBRbjVu/now= boy10@naver.com
Output for 5.4.14
Key size: 7 ukBDJR1Bis0Y40gN0oh7comi8LWYUt14WdJWHDHzHHA= boy10@naver.com
Output for 5.4.13
Key size: 7 i0N7HFkkNZE3PizwKCoT5DNw89k9rNu6vckrvDXDO7A= boy10@naver.com
Output for 5.4.12
Key size: 7 mbrNz2MSGtzpHQnND4KBfVUdNXrNPs0pLTqPfwscor8= boy10@naver.com
Output for 5.4.11
Key size: 7 0Nv2iADUnEADnHVec6M6GR2hkfwmNGoHaPHo0UXVP4c= boy10@naver.com
Output for 5.4.10
Key size: 7 nC1WqY1JbITPQkAdYHGBsve9T14bbQITepff3YsfBBU= boy10@naver.com