3v4l.org

run code in 300+ PHP versions simultaneously
<?php $encAlgo = 'rijndael-256'; $encMode = 'ecb'; function encrypt_base64_urlenc($secret, $shared) { global $encAlgo; global $encMode; $secret .= '\0'; return rawurlencode( base64_encode( trim(mcrypt_encrypt( $encAlgo, $shared, $secret, $encMode, mcrypt_create_iv( mcrypt_get_iv_size( $encAlgo, $encMode ), 2 ) ), "\0") ) ); } function decrypt_base64($secret, $shared) { global $encAlgo; global $encMode; $result = trim(mcrypt_decrypt( $encAlgo, $shared, base64_decode(strtr($secret,' ','+')), $encMode, mcrypt_create_iv( mcrypt_get_iv_size( $encAlgo, $encMode ), 2 ) ), "\0"); $terminator = strpos($result, '\0'); if ( $terminator !== -1 ) return substr($result, 0, $terminator); return $result; } $test = encrypt_base64_urlenc('thisisatest','derpderp'); echo "$test\n"; $decd = decrypt_base64(rawurldecode($test),'derpderp'); echo "$decd\n"; $v = 'UQZv+VpZTlLkjPSaNnkrnDUMXH1pHKb/Jd7Aq+g9exo='; $k = base64_decode('WOZ5NTIR9HrGM6bdehY0LMG8rmnnvplUprgSJE4cl1Y='); echo decrypt_base64($v, $k);
Output for 7.0.20, 7.1.5 - 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.6
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/WR7UG:12 Stack trace: #0 /in/WR7UG(52): encrypt_base64_urlenc('thisisatest\\0', 'derpderp') #1 {main} thrown in /in/WR7UG on line 12
Process exited with code 255.
Output for 7.0.6 - 7.0.14, 7.1.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/WR7UG:10 Stack trace: #0 /in/WR7UG(52): encrypt_base64_urlenc('thisisatest\\0', 'derpderp') #1 {main} thrown in /in/WR7UG on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.5
Warning: mcrypt_encrypt(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/WR7UG on line 22 Warning: mcrypt_decrypt(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/WR7UG on line 43
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.35, 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_encrypt() in /in/WR7UG on line 12
Process exited with code 255.
Output for 5.6.7 - 5.6.20
Warning: mcrypt_encrypt(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/WR7UG on line 24 Warning: mcrypt_decrypt(): Key of size 8 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/WR7UG on line 45
Output for 5.4.36 - 5.4.45, 5.5.24 - 5.5.34
t%2FdAmXIbQ5tX67IH0B6ozrjKzsO19zWpaFhw0wBhW58%3D thisisatest
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/WR7UG on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/WR7UG on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/WR7UG on line 12

preferences:
225.02 ms | 401 KiB | 328 Q