3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set the method $method = 'AES-128-CBC'; // Set the encryption key $encryption_key = 'myencryptionkey'; // Generet a random initialisation vector $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method)); // Define the date to be encrypted $data = "Encrypt me, please!"; var_dump("Before encryption: $data"); // Encrypt the data $encrypted = openssl_encrypt($data, $method, $encryption_key, 0, $iv); var_dump("Encrypted: ${encrypted}"); // Append the vector at the end of the encrypted string $encrypted = $encrypted . ':' . $iv; var_dump($encrypted); // Explode the string using the `:` separator. $parts = explode(':', $encrypted); var_dump("COUNT: " . count($parts)); // Decrypt the data $decrypted = openssl_decrypt($parts[0], $method, $encryption_key, 0, $parts[1]); var_dump("Decrypted: ${decrypted}");
Output for git.master_jit, git.master, rfc.property-hooks
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/3ObfJ on line 21 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/3ObfJ on line 34 Fatal error: Uncaught Error: Call to undefined function openssl_random_pseudo_bytes() in /in/3ObfJ:11 Stack trace: #0 {main} thrown in /in/3ObfJ on line 11
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:
36.54 ms | 401 KiB | 8 Q