3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encrypt($decrypted, $password, $salt='123456789') { $key = hash('SHA256', $salt . $password, true); srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND); if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22) return false; $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted . md5($decrypted), MCRYPT_MODE_CBC, $iv)); return $iv_base64 . $encrypted; } function decrypt($encrypted, $password, $salt='123456789') { $key = hash('SHA256', $salt . $password, true); $iv = base64_decode(substr($encrypted, 0, 22) . '=='); $encrypted = substr($encrypted, 22); $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4"); $hash = substr($decrypted, -32); $decrypted = substr($decrypted, 0, -32); if (md5($decrypted) != $hash) return false; return $decrypted; } print_r (encrypt(" mi texto","asdf")); echo "\n"; print_r ("= " + decrypt(encrypt(" mi texto","asdf"),"asdf")); echo "\n";
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mcrypt_create_iv() in /in/kGfSq:5 Stack trace: #0 /in/kGfSq(24): encrypt(' mi texto', 'asdf') #1 {main} thrown in /in/kGfSq on line 5
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:
170.15 ms | 405 KiB | 5 Q