3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CRYPT { public function encrypt($Str,$Key=ENCKEY) { srand(); $Str=str_pad($Str, 32-strlen($Str)); $IVSize=mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $IV=mcrypt_create_iv($IVSize, MCRYPT_RAND); $CryptStr=mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $Key, $Str, MCRYPT_MODE_CBC, $IV); return base64_encode($IV.$CryptStr); } public function decrypt($CryptStr,$Key=ENCKEY) { if ($CryptStr!='') { $IV=substr(base64_decode($CryptStr),0,16); $CryptStr=substr(base64_decode($CryptStr),16); return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $Key, $CryptStr, MCRYPT_MODE_CBC,$IV)); } else { return ''; } } } // class ENCRYPT() $enc = new CRYPT; $s = "test"; //$s = "FGykgbMFQiTpVIRhO9HWL/wXYevfsd7ozE99pbDWge/2Fs8fQb1iqeaw3yAe+kLsmTgPUz7mo/sTfEsvEfldWEx9XU51gsM6T1othRV6rshB9ThE3BOOUKKnhqt/gYyUP6POu5HSr7Rem7TIJIEAPh4w1cTQNN2ZCXyYS4Y+C/8="; $test = $enc->encrypt($s, "w+2#)1FP&LIPTL2<8I2"); //echo $test; echo $enc->decrypt("4OkyDTPIuCi3PcQr5xwrkhWYHDu3J8loHA/D12BwVNTRk+gziMZYbCNCcIO0du92", "w+2#)1FP&LIPTL2<8I2");
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
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/NJfv1:7 Stack trace: #0 /in/NJfv1(28): CRYPT->encrypt('test ...', 'w+2#)1FP&LIPTL2...') #1 {main} thrown in /in/NJfv1 on line 7
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/NJfv1:7 Stack trace: #0 /in/NJfv1(28): CRYPT->encrypt('test ...', 'w+2#)1FP&LIPTL2...') #1 {main} thrown in /in/NJfv1 on line 7
Process exited with code 255.
Output for 5.6.8 - 5.6.20, 7.0.0 - 7.0.5
Warning: mcrypt_encrypt(): Key of size 19 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/NJfv1 on line 9 Warning: mcrypt_decrypt(): Key of size 19 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/NJfv1 on line 17
Output for 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_get_iv_size() in /in/NJfv1 on line 7
Process exited with code 255.
Output for 5.5.24 - 5.5.34
test

preferences:
189.31 ms | 401 KiB | 198 Q