3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Crypter{ private $Key; private $Algo; public function __construct($Algo = MCRYPT_BLOWFISH) { $this->Key = substr('key', 0, mcrypt_get_key_size($Algo, MCRYPT_MODE_ECB)); $this->Algo = $Algo; } public function Encrypt($data) { //$iv_size = mcrypt_get_iv_size($this->Algo, MCRYPT_MODE_ECB); //$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $blocksize = mcrypt_get_block_size('blowfish', 'ecb'); // get block size $pkcs = $blocksize - (strlen($data) % $blocksize); // get pkcs5 pad length $data.= str_repeat(chr($pkcs), $pkcs); // append pkcs5 padding to the data $crypt = mcrypt_encrypt($this->Algo, $this->Key, $data, MCRYPT_MODE_ECB); return rtrim(base64_encode($crypt)); } public function Decrypt($data) { $crypt = base64_decode($data); $iv_size = mcrypt_get_iv_size($this->Algo, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypt = mcrypt_decrypt($this->Algo, $this->Key, $crypt, MCRYPT_MODE_ECB, $iv); return rtrim($decrypt); } } $crypter = new Crypter(); $data = "Some data to encrypt"; $encryptedData = $crypter->Encrypt($crypter); $decryptedData = $crypter->Decrypt($encryptedDate); echo "Decripted Data = [$decryptedData]\n";
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant "MCRYPT_BLOWFISH" in /in/EZTeG:7 Stack trace: #0 /in/EZTeG(39): Crypter->__construct() #1 {main} thrown in /in/EZTeG on line 7
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:
47.6 ms | 401 KiB | 8 Q