3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "secret"; function getKey($seed='no seed??') { return hash('sha256', $seed, 1); } function encrypt($key, $string) { $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($size, MCRYPT_RAND); $encrypted_string = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv); return base64_encode($iv . $encrypted_string); } function decrypt($key, $encoded_string) { $binary = base64_decode($encoded_string); $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); $iv = substr($binary, 0, $size); $encrypted_string = substr($binary, $size); return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted_string, MCRYPT_MODE_CBC, $iv); } $key = getKey('Some Secret String'); $encrypted = encrypt($key, 'This is a string that will be encrypted'); echo decrypt($key, $encrypted);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_iv_size() in /in/diXEM:9 Stack trace: #0 /in/diXEM(26): encrypt('\x18\xAA\x853\xF6\xBD\xC1\xE3"\xEB\x078\xE5G\xC1...', 'This is a strin...') #1 {main} thrown in /in/diXEM on line 9
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.92 ms | 401 KiB | 8 Q