3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Name: PHP Encryption: Desc: Encrypt and Decrypt data. Version: V1.0 Date: 3/11/2017 Author: Prince Adeyemi Contact: prince@vegasnewspaper.com Facebook: fb.com/YourVegasPrince */ // Encryption setup: $dataToEncrypt = "My Secret Telegram: Hakuna matata! hhgggg"; $encryptMethod = "AES-256-CBC"; $mySecretHash = "somethingRandom12!)!)I!@1U2 goes gere"; //$iv = mcrypt_create_iv(16, MCRYPT_RAND); // php versopm 5.6.0- 7.2.x compability; If( phpversion() >= 7) { $bytes = random_bytes(8); $iv = (bin2hex($bytes)); } elseif( phpversion() < 7 ) { for ($i = -1; $i <= 16; $i++) { $iv = openssl_random_pseudo_bytes($i, $cstrong); } } else { $iv = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM); } //Encrypt data: $encryptedData = openssl_encrypt($dataToEncrypt,$encryptMethod,$mySecretHash, 0, $iv); //Decrypt data: $decryptedData = openssl_decrypt($encryptedData, $encryptMethod, $mySecretHash, 0, $iv); //OUTPUT: echo ("RandomIV : " . $iv . "\n"); echo ( "Secret message : " . $dataToEncrypt ."\n" ); echo ( "Encrypted message : ". $encryptedData ."\n" ); echo ( "Decrypted message: ". $decryptedData ."\n"); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.10.0210.00718.04
7.2.00.0230.01317.79
7.1.130.0140.01016.56
7.1.120.0220.01116.91
7.1.110.0190.00916.36
7.1.100.0240.00316.17
7.1.90.0260.00615.91
7.1.80.0150.01216.46
7.1.70.0190.00915.34
7.1.60.0360.00633.50
7.1.50.0220.01433.16
7.1.40.0410.01332.53
7.1.30.0260.01332.75
7.1.20.0340.00932.80
7.1.10.0170.00714.63
7.1.00.0120.01614.74

preferences:
35.98 ms | 401 KiB | 5 Q