3v4l.org

run code in 300+ PHP versions simultaneously
<?php function password_encrypt($password){ $hash_format = "$2y$10$"; $salt_length = 22; $salt = generate_salt($salt_length); $format_and_salt = $hash_format . $salt; $hash = crypt($password, $format_and_salt); return $hash; } function generate_salt($length){ // Not 100% unique, not 100% random, but good enough for a salt // MD5 returns 32 characters $unique_random_string = md5(uniqid(mt_rand(), true)); // Valid characters for a salt are [a-zA-Z0-9./] $base64_string = base64_encode($unique_random_string); // But not '+' which is valid in base64 encoding $modified_base64_string = str_replace('+', '.', $base64_string); // Truncate string to the correct length $salt = substr($modified_base64_string, 0, $length); return $salt; } function password_check($password, $existing_hash) { // existing hash contains format and salt at start $hash = crypt($password, $existing_hash); if ($hash === $existing_hash) { return true; } else { return false; } } if(password_check(3301386, "$2y$10$MzU3ODMzOGE0MGEwMzI3OOi8QVkhZmXTwdWbdx9c7F6DxuZyyAO2q"){ echo "found!"; }

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.0.90.0070.06020.00
7.0.80.0100.05719.96
7.0.70.0130.05319.99
7.0.60.0130.05019.91
7.0.50.0170.06720.41
7.0.40.0230.05020.41
7.0.30.0100.06020.33
7.0.20.0100.06020.21
7.0.10.0100.07320.40
7.0.00.0230.05020.32
5.6.240.0130.06320.77
5.6.230.0130.05720.59
5.6.220.0170.05320.50
5.6.210.0070.06020.55
5.6.200.0030.06321.12
5.6.190.0170.05021.13
5.6.180.0300.06021.14
5.6.170.0130.06321.11
5.6.160.0200.04721.01
5.6.150.0170.06721.09
5.6.140.0100.06321.08
5.6.130.0170.05721.09
5.6.120.0100.06721.18
5.6.110.0100.08721.09
5.6.100.0100.06021.18
5.6.90.0030.08021.07
5.6.80.0070.05720.48
5.6.70.0070.08720.47
5.6.60.0070.06020.47
5.6.50.0300.06020.42
5.6.40.0000.07020.36
5.6.30.0070.08720.38
5.6.20.0070.06720.56
5.6.10.0170.08020.38
5.6.00.0100.06020.47

preferences:
143.34 ms | 1394 KiB | 7 Q