$password = "your_password";
Hash the password with cost factor
9
$start9 = microtime(true);
$hash9 = password_hash($password, PASSWORD_BCRYPT, ['cost' => 9]);
$end9 = microtime(true);
$executionTime9 = $end9 - $start9;
Hash the password with cost factor
10
$start10 = microtime(true);
$hash10 = password_hash($password, PASSWORD_BCRYPT, ['cost' => 10]);
$end10 = microtime(true);
$executionTime10 = $end10 - $start10;
Calculate the speedup factor
$speedupFactor = $executionTime10 / $executionTime9;

// Display the hashed passwords, execution times, and speedup factor
echo "Hashed password with cost 9: " . $hash9 . "\n";
echo "Execution time with cost 9: " . $executionTime9 . " seconds\n\n";
echo "Hashed password with cost 10: " . $hash10 . "\n";
echo "Execution time with cost 10: " . $executionTime10 . " seconds\n\n";
echo "Speedup factor (9 vs 10): " . $speedupFactor . " times faster\n";
by Valeri Tandilashvili
11 months ago
PHP
Password hashing
0
Pro tip: use ```triple backticks around text``` to write in code fences