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'; 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, $salt)) . "\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.60.0150.00916.81
7.4.50.0150.00616.57
7.4.40.0120.00616.32
7.4.30.0180.00016.61
7.4.20.0120.00816.64
7.4.10.0150.00416.36
7.4.00.0100.01116.00
7.3.180.0080.01416.49
7.3.170.0120.00616.58
7.3.160.0090.00916.48
7.3.150.0090.00916.74
7.3.140.0030.01416.44
7.3.130.0150.00316.53
7.3.120.0110.00815.89
7.3.110.0070.01215.91
7.3.100.0060.01115.80
7.3.90.0030.01115.81
7.3.80.0100.00615.99
7.3.70.0030.01115.81
7.3.60.0050.01115.82
7.3.50.0030.01215.70
7.3.40.0120.00515.72
7.3.30.0060.01115.86
7.3.20.0040.01017.42
7.3.10.0080.00817.70
7.3.00.0100.00717.75
7.2.310.0060.01417.00
7.2.300.0090.00916.73
7.2.290.0060.01516.71
7.2.280.0140.01116.92
7.2.270.0050.01316.77
7.2.260.0100.01316.91
7.2.250.0130.00815.97
7.2.240.0040.01616.09
7.2.230.0070.00815.99
7.2.220.0040.01116.20
7.2.210.0060.00916.03
7.2.200.0130.00515.98
7.2.190.0090.00616.17
7.2.180.0120.00816.14
7.2.170.0030.01516.00
7.2.160.0030.01516.77
7.2.150.0160.00318.76
7.2.140.0170.00318.64
7.2.130.0140.00718.75
7.2.120.0130.00618.60
7.2.110.0060.01518.71
7.2.100.0070.01418.71
7.2.90.0140.01418.63
7.2.80.0110.01618.77
7.2.70.0150.01018.77
7.2.60.0040.02018.80
7.2.50.0080.01118.56
7.2.40.0060.01318.70
7.2.30.0030.01618.70
7.2.20.0130.01018.84
7.2.10.0040.01618.58
7.2.00.0030.01219.38
7.1.330.0140.00816.72
7.1.320.0150.00716.90
7.1.310.0080.01516.61
7.1.300.0130.00716.90
7.1.290.0160.00716.82
7.1.280.0140.01016.87
7.1.270.0140.00716.91
7.1.260.0160.00916.96
7.1.250.0200.01317.79
7.1.240.0180.01417.52
7.1.230.0270.00617.43
7.1.220.0250.00717.46
7.1.210.0230.01717.60
7.1.200.0290.00417.57
7.1.190.0120.01517.57
7.1.180.0110.00817.57
7.1.170.0120.00917.51
7.1.160.0140.00917.42
7.1.150.0180.00717.63
7.1.140.0060.02317.41
7.1.130.0210.01317.40
7.1.120.0220.00817.32
7.1.110.0140.01417.57
7.1.100.0080.01217.80
7.1.90.0140.01417.45
7.1.80.0180.00917.57
7.1.70.0100.01017.49
7.1.60.0140.00717.32
7.1.50.0120.01517.29
7.1.40.0300.00017.79
7.1.30.0220.00717.83
7.1.20.0160.01617.57
7.1.10.0190.01017.48
7.1.00.0150.04020.00
7.0.330.0130.01617.16
7.0.320.0160.01317.18
7.0.310.0280.00317.21
7.0.300.0280.00817.22
7.0.290.0160.01317.28
7.0.280.0210.00917.33
7.0.270.0150.01517.36
7.0.260.0240.00417.16
7.0.250.0230.00617.39
7.0.240.0220.00817.45
7.0.230.0280.00517.21
7.0.220.0280.01217.40
7.0.210.0160.01317.23
7.0.200.0210.01116.36
7.0.190.0230.01017.36
7.0.180.0310.00317.30
7.0.170.0200.00917.42
7.0.160.0230.00817.17
7.0.150.0240.00917.12
7.0.140.0160.02017.43
7.0.130.0210.01117.33
7.0.120.0270.04318.84
7.0.110.0310.04218.79
7.0.100.0210.04618.90
7.0.90.0260.03818.84
7.0.80.0280.03318.89
7.0.70.0290.03118.77
7.0.60.0280.03718.84
7.0.50.0300.02818.86
7.0.40.0300.04018.78
7.0.30.0240.03518.82
7.0.20.0320.03218.78
7.0.10.0240.03818.64
7.0.00.0220.04118.82
5.6.400.0180.01716.00
5.6.390.0240.00616.16
5.6.380.0260.01315.99
5.6.370.0190.02315.85
5.6.360.0210.01515.86
5.6.350.0180.01115.97
5.6.340.0230.01016.12
5.6.330.0220.01116.00
5.6.320.0260.00515.91
5.6.310.0250.01016.27
5.6.300.0100.02115.73
5.6.290.0210.01015.77
5.6.280.0190.01415.99
5.6.270.0210.01315.92
5.6.260.0200.02918.61
5.6.250.0160.05018.42
5.6.240.0240.02918.53
5.6.230.0110.04118.47
5.6.220.0170.03218.34
5.6.210.0150.03718.54
5.6.200.0140.03718.31
5.6.190.0110.03718.39
5.6.180.0160.03518.52
5.6.170.0160.04318.45
5.6.160.0150.03318.46
5.6.150.0230.03018.42
5.6.140.0170.03718.49
5.6.130.0150.04318.49
5.6.120.0130.03718.40
5.6.110.0100.04018.35
5.6.100.0160.03618.45
5.6.90.0220.03118.62
5.6.80.0250.02318.16
5.6.70.0250.03418.29
5.6.60.0150.03318.04
5.6.50.0260.02018.21
5.6.40.0170.02918.05
5.6.30.0140.03218.01
5.6.20.0150.03118.19
5.6.10.0210.03118.18
5.6.00.0160.03417.99

preferences:
36.14 ms | 400 KiB | 5 Q