3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decryptData($value){ $key = "ICS2015"; $crypttext = base64_decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv); return trim($decrypttext); } function encryptData($value) { $key = "ICS2015"; $text = $value; // getting the size of the IV (Initialization Vector) belonging to a specific cipher / mode combination // Accept two params // 1: cipher (MCPYPT_ciphername constraint or the name of algorithms string) // 2: mode (MCPYPT_MODE_modename constraint or one of the following string - ecb, cbc, cfb, ofb, nofb or stream ) $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); // Create an initialization vector(IV) from RANDOM source $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); // Encrypt plaintext with given params $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); return base64_encode($crypttext); } $data = 'testdata'; $encData = encryptData($data); $decData = decryptData($encData); echo $data; echo $encData; echo $decData; ?>
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 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
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/AZM5H:22 Stack trace: #0 /in/AZM5H(33): encryptData('testdata') #1 {main} thrown in /in/AZM5H on line 22
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 Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/AZM5H:22 Stack trace: #0 /in/AZM5H(33): encryptData('testdata') #1 {main} thrown in /in/AZM5H on line 22
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function mcrypt_get_iv_size() in /in/AZM5H on line 22
Process exited with code 255.

preferences:
245.14 ms | 402 KiB | 327 Q