3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AESEncryptExampleClass { public function _encrypt($plaintext, $passphrase, $keySize, $salt, $iv, $iterationCount) { $mode = MCRYPT_MODE_CBC; //Generate AES encryption key $key = $this->_pbkdf2($passphrase, "e84ad660c4721ae0e84ad660c4721ae0", $iterationCount, $this->_parseKeyInt(MCRYPT_RIJNDAEL_128)); echo base64_encode($key) . "\n"; try { $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $this->_pkcs5Pad($plaintext), $mode, $iv); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } return (base64_encode($ciphertext)); } public function _getRandomBytes($length = 8) { $characters = '0123456789'; $charactersLength = strlen($characters) - 1; $bytes = ''; //Select some random characters for ($i = 0; $i < $length; $i++) { $bytes .= $characters[mt_rand(0, $charactersLength)]; } return $bytes; } private function _pbkdf2($passphrase, $salt, $iterationCount = 1000, $keyLength = MCRYPT_RIJNDAEL_128, $algorithm = 'sha1') { $hashLength = strlen( hash( $algorithm, null, true ) ); $blockCount = ceil( $keyLength / $hashLength ); $output = ''; //Create key for ( $block = 1; $block <= $blockCount; $block++ ) { //Initial hash for this block $xorsum = $last = hash_hmac( $algorithm, $salt . pack( 'N', $block ), $passphrase, true ); //Perform block iterations for ( $i = 1; $i < $iterationCount; $i++ ) { //XOR each iterate $xorsum ^= ( $last = hash_hmac( $algorithm, $last, $passphrase, true ) ); } //Append iterated block $output .= $xorsum; } //Return derived key of correct length return substr( $output, 0, $keyLength ); } private function _parseKeyInt($keySize) { $key = ""; if ($keySize == MCRYPT_RIJNDAEL_128) { $key = 16; } else if ($keySize == MCRYPT_RIJNDAEL_192) { $key = 24; } else if ($keySize == MCRYPT_RIJNDAEL_256) { $key = 32; } return $key; } private function _pkcs5Pad($text) { $blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $padding = $blockSize - (strlen($text) % $blockSize); $text .= str_repeat(chr($padding), $padding); return $text; } } /*-----------------------------------------------------------* * EXAMPLE USING AESEncryptExampleClass * *-----------------------------------------------------------*/ $iterationCount = 1000; $keySize = 128; $youmapsKey = "YOUR_YOUMAPS_KEY"; $url = "exampleURL"; //Initialize AESEncryptExampleClass $aesEncrypt = new AESEncryptExampleClass(); //Generate random IV and salt $salt = "1234567891234567"; $iv = "1234567891234567"; //$salt = $aesEncrypt->_getRandomBytes(16); //$iv = $aesEncrypt->_getRandomBytes(16); //Encrypt the URL $encryptedURL = $aesEncrypt->_encrypt($url, $youmapsKey, $keySize, $salt, $iv, $iterationCount); echo $encryptedURL; ?>

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.4.10.0100.01015.07
7.4.00.0080.01114.82
7.3.130.0070.01414.82
7.3.120.0080.01214.71
7.3.110.0030.01514.96
7.3.100.0070.00814.96
7.3.90.0080.00814.92
7.3.80.0070.00914.78
7.3.70.0070.00914.88
7.3.60.0040.00914.85
7.3.50.0040.00914.80
7.3.40.0050.00514.82
7.3.30.0050.01014.94
7.3.20.0110.00316.85
7.3.10.0060.00816.60
7.3.00.0070.00916.87
7.2.260.0060.01515.20
7.2.250.0120.00815.03
7.2.240.0100.00715.10
7.2.230.0070.01115.30
7.2.220.0060.00915.00
7.2.210.0050.01215.09
7.2.200.0060.00715.09
7.2.190.0070.00615.17
7.2.180.0050.01115.00
7.2.170.0030.00815.16
7.2.160.0000.01614.94
7.2.150.0050.00517.01
7.2.140.0120.00316.84
7.2.130.0040.00817.03
7.2.120.0090.00616.85
7.2.110.0070.01016.93
7.2.100.0030.00717.09
7.2.90.0080.00716.87
7.2.80.0030.01017.07
7.2.70.0120.00316.92
7.2.60.0070.00716.74
7.2.50.0100.00616.71
7.2.40.0070.01017.11
7.2.30.0000.01116.81
7.2.20.0040.01417.01
7.2.10.0070.00416.79
7.2.00.0050.00718.24
7.1.330.0050.01115.84
7.1.320.0040.01115.71
7.1.310.0080.01015.92
7.1.300.0080.00515.75
7.1.290.0070.00715.91
7.1.280.0040.01215.71
7.1.270.0050.01015.68
7.1.260.0040.01215.75
7.1.250.0030.00915.88
7.1.240.0090.00915.61
7.1.230.0030.01315.85
7.1.220.0030.01315.83
7.1.210.0090.00016.01
7.1.200.0110.00715.69
7.1.190.0030.01015.82
7.1.180.0130.00315.61
7.1.170.0070.00316.02
7.1.160.0090.00615.77
7.1.150.0040.00715.84
7.1.140.0030.00715.96
7.1.130.0040.01115.58
7.1.120.0000.01515.71
7.1.110.0030.00615.89
7.1.100.0090.00615.90
7.1.90.0030.01315.86
7.1.80.0030.00715.78
7.1.70.0080.00816.36
7.1.60.0030.01017.36
7.1.50.0060.00816.29
7.1.40.0060.00915.91
7.1.30.0100.00615.84
7.1.20.0040.01115.88
7.1.10.0060.00615.86
7.1.00.0050.04519.09
7.0.330.0000.00915.41
7.0.320.0070.00715.50
7.0.310.0000.01015.46
7.0.300.0000.01015.36
7.0.290.0060.00915.30
7.0.280.0030.01315.30
7.0.270.0040.01115.55
7.0.260.0060.00315.23
7.0.250.0000.01015.33
7.0.240.0030.01315.29
7.0.230.0100.00715.45
7.0.220.0090.00015.22
7.0.210.0000.01615.48
7.0.200.0040.01016.06
7.0.190.0060.01215.32
7.0.180.0000.01615.43
7.0.170.0030.00615.31
7.0.160.0040.01415.57
7.0.150.0060.00915.56
7.0.140.0070.00715.32
7.0.130.0030.01515.31
7.0.120.0070.00715.31
7.0.110.0100.00615.50
7.0.100.0070.04417.80
7.0.90.0060.03817.55
7.0.80.0020.04917.67
7.0.70.0170.03217.70
7.0.60.0000.05217.75
7.0.50.0050.04318.04
7.0.40.0070.04716.75
7.0.30.0080.04816.82
7.0.20.0050.04216.72
7.0.10.0110.04416.81
7.0.00.0120.04216.74
5.6.400.0030.01214.12
5.6.390.0030.01014.19
5.6.380.0070.00414.32
5.6.370.0000.01614.50
5.6.360.0070.00714.39
5.6.350.0000.01414.64
5.6.340.0040.01114.12
5.6.330.0090.00614.38
5.6.320.0030.01514.41
5.6.310.0070.01114.71
5.6.300.0080.00614.58
5.6.290.0070.01014.35
5.6.280.0070.03717.60
5.6.270.0030.01214.68
5.6.260.0070.00714.41
5.6.250.0070.03017.51
5.6.240.0050.05317.48
5.6.230.0030.04917.52
5.6.220.0030.04317.49
5.6.210.0070.03517.41
5.6.200.0020.04417.82
5.6.190.0080.03017.66
5.6.180.0120.04317.87
5.6.170.0050.02917.84
5.6.160.0070.03917.79
5.6.150.0030.05317.77
5.6.140.0030.04017.83
5.6.130.0080.04417.73
5.6.120.0080.04717.88
5.6.110.0130.04017.89
5.6.100.0030.04717.92
5.6.90.0000.05317.62
5.6.80.0100.03017.45
5.6.70.0170.03717.33
5.6.60.0050.04917.37
5.6.50.0090.04417.44
5.6.40.0020.05217.54
5.6.30.0040.05217.50
5.6.20.0110.04017.28
5.6.10.0130.03817.46
5.6.00.0050.05017.43
5.5.380.0070.04317.43
5.5.370.0060.04617.29
5.5.360.0050.03317.21
5.5.350.0090.04417.21
5.5.340.0050.04217.59
5.5.330.0040.05117.55
5.5.320.0070.04917.50
5.5.310.0100.04517.70
5.5.300.0090.03817.60
5.5.290.0050.04917.66
5.5.280.0080.03717.73
5.5.270.0070.03517.59
5.5.260.0070.03517.52
5.5.250.0140.03917.65
5.5.240.0030.04517.13
5.5.230.0070.04817.39
5.5.220.0090.03917.29
5.5.210.0070.03317.24
5.5.200.0110.03817.43
5.5.190.0060.05317.28
5.5.180.0080.04817.34
5.5.170.0030.01014.13
5.5.160.0110.02417.26
5.5.150.0080.03017.16
5.5.140.0080.04417.31
5.5.130.0050.04517.27
5.5.120.0090.03117.45
5.5.110.0050.04717.22
5.5.100.0080.04717.33
5.5.90.0140.03716.97
5.5.80.0150.02717.16
5.5.70.0100.04017.27
5.5.60.0100.04017.24
5.5.50.0080.04217.12
5.5.40.0030.04317.15
5.5.30.0080.04217.23
5.5.20.0110.02817.17
5.5.10.0080.04117.11
5.5.00.0100.03817.24

preferences:
33.23 ms | 400 KiB | 5 Q