3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCryptedPassword($plaintext, $salt = '', $encryption = 'crypt-blowfish', $show_encrypt = false) { // mimic the getSalt function so we can use it in the example. if ($salt) { $salt = substr(preg_replace('|^{crypt}|i', '', $salt), 0, 16); } else { if (function_exists('random_bytes')) { $salt = '$2$' . substr(md5(random_bytes(16)), 0, 12) . '$'; } else { // Fake the salt result (a previously generated salt using https://github.com/paragonie/random_compat ) $salt = '$2$9936b047ea8b$'; } } // Encrypt the password. switch ($encryption) { case 'plain': return $plaintext; case 'sha': $encrypted = base64_encode(mhash(MHASH_SHA1, $plaintext)); return ($show_encrypt) ? '{SHA}' . $encrypted : $encrypted; case 'crypt': case 'crypt-des': case 'crypt-md5': case 'crypt-blowfish': return ($show_encrypt ? '{crypt}' : '') . crypt($plaintext, $salt); case 'md5-hex': default: $encrypted = ($salt) ? md5($plaintext . $salt) : md5($plaintext); return ($show_encrypt) ? '{MD5}' . $encrypted : $encrypted; } } $plaintext = 'mySuperSecretPassword'; $salt = ''; if (function_exists('random_bytes')) { $salt = '$2$' . substr(md5(random_bytes(16)), 0, 12) . '$'; } else { // Fake the salt result (a previously generated salt using https://github.com/paragonie/random_compat ) $salt = '$2$9936b047ea8b$'; } echo strlen(crypt($plaintext, '$2$' . substr(md5(random_bytes(16)), 0, 12) . '$')) . "\n"; echo crypt($plaintext, '$2$' . substr(md5(random_bytes(16)), 0, 12) . '$') . "\n"; echo strlen(getCryptedPassword($plaintext, $salt, 'crypt-blowfish')) . "\n"; echo getCryptedPassword($plaintext, $salt, 'crypt-blowfish');

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.00.0070.01015.29
7.3.120.0120.00614.96
7.3.110.0060.01115.02
7.3.100.0090.00915.12
7.3.90.0050.00515.05
7.3.80.0040.01614.98
7.3.70.0080.00415.14
7.3.60.0000.01415.15
7.3.50.0030.00915.14
7.3.40.0000.00814.98
7.3.30.0070.00714.92
7.3.20.0090.00016.66
7.3.10.0070.00716.81
7.3.00.0070.00716.96
7.2.250.0070.01115.21
7.2.240.0040.01515.49
7.2.230.0100.00315.55
7.2.220.0100.00715.01
7.2.210.0030.00715.24
7.2.200.0090.00615.23
7.2.190.0040.01115.49
7.2.180.0030.01015.46
7.2.170.0030.01015.36
7.2.160.0110.00415.26
7.2.150.0130.00317.26
7.2.140.0070.00717.12
7.2.130.0030.01016.82
7.2.120.0030.00617.05
7.2.110.0070.00717.28
7.2.100.0030.01017.17
7.2.90.0120.00317.30
7.2.80.0030.01217.01
7.2.70.0070.00317.04
7.2.60.0060.00817.13
7.2.50.0060.00617.07
7.2.40.0030.01016.80
7.2.30.0140.00017.26
7.2.20.0070.00717.24
7.2.10.0070.00717.19
7.2.00.0060.01018.37
7.1.330.0040.00716.26
7.1.320.0100.01015.92
7.1.310.0040.00816.18
7.1.300.0110.00015.88
7.1.290.0070.00716.05
7.1.280.0070.00315.90
7.1.270.0060.00316.16
7.1.260.0070.00715.77
7.1.250.0000.00816.02
7.1.240.0060.01016.00
7.1.230.0040.00416.15
7.1.220.0060.00915.98
7.1.210.0000.01616.09
7.1.200.0060.00816.01
7.1.190.0060.00615.90
7.1.180.0060.00616.09
7.1.170.0060.00616.24
7.1.160.0040.01115.91
7.1.150.0000.01416.00
7.1.140.0120.00015.98
7.1.130.0030.00716.07
7.1.120.0030.00616.16
7.1.110.0080.00416.08
7.1.100.0030.01117.22
7.1.90.0090.00315.89
7.1.80.0000.01415.97
7.1.70.0080.00316.89
7.1.60.0060.00616.77
7.1.50.0050.01316.59
7.1.40.0030.01316.04
7.1.30.0000.01516.10
7.1.20.0000.01515.89
7.1.10.0030.01015.86
7.1.00.0000.04719.20
7.0.330.0040.01115.54
7.0.320.0070.00715.46
7.0.310.0040.00415.77
7.0.300.0040.00815.73
7.0.290.0040.01115.36
7.0.280.0100.00315.56
7.0.270.0070.00315.80
7.0.260.0080.00015.70
7.0.250.0070.00715.54
7.0.240.0070.00315.59
7.0.230.0030.01315.74
7.0.220.0060.00915.56
7.0.210.0070.00715.81
7.0.200.0170.00915.20
7.0.190.0040.01115.55
7.0.180.0030.00615.66
7.0.170.0000.01315.48
7.0.160.0070.00415.51
7.0.150.0000.01415.72
7.0.140.0040.00715.71
7.0.130.0070.00715.77
7.0.120.0250.03418.04
7.0.110.0190.03518.00
7.0.100.0230.02417.95
7.0.90.0180.03518.08
7.0.80.0240.03817.95
7.0.70.0220.03817.84
7.0.60.0210.03317.85
7.0.50.0180.03818.08
7.0.40.0230.03616.99
7.0.30.0260.02617.10
7.0.20.0180.03317.03
7.0.10.0200.03217.03
7.0.00.0200.03517.00
5.6.400.0000.00913.99
5.6.390.0030.00614.55
5.6.380.0000.00814.33
5.6.370.0030.00914.54
5.6.360.0040.00814.54
5.6.350.0060.00914.35
5.6.340.0040.00714.02
5.6.330.0080.00814.32
5.6.320.0060.00314.00
5.6.310.0030.01214.06
5.6.300.0040.01214.35
5.6.290.0040.00814.07
5.6.280.0100.00314.25
5.6.270.0030.01014.25
5.6.260.0100.03217.52
5.6.250.0080.03517.81
5.6.240.0100.03317.66
5.6.230.0100.03517.54
5.6.220.0080.03117.46
5.6.210.0050.03717.69
5.6.200.0100.03217.67
5.6.190.0050.04517.63
5.6.180.0150.03217.57
5.6.170.0060.03317.62
5.6.160.0100.02917.54
5.6.150.0030.03817.58
5.6.140.0020.03817.62
5.6.130.0080.03117.48
5.6.120.0080.03817.41
5.6.110.0070.03617.45
5.6.100.0070.03817.63
5.6.90.0150.02717.55
5.6.80.0100.03217.27
5.6.70.0130.03217.33
5.6.60.0120.03817.23
5.6.50.0080.03117.17
5.6.40.0120.03717.22
5.6.30.0100.02817.22
5.6.20.0070.03317.30
5.6.10.0080.03417.20
5.6.00.0140.02717.10

preferences:
57.62 ms | 400 KiB | 5 Q