r/AskComputerScience • u/benmarvin • Apr 08 '26
Why does it take my computer slightly longer to tell me when I've entered the wrong login password than when I enter the right password?
I've noticed this on both Windows and Linux. If I enter the correct password, it almost instantly starts the login. But if it's the wrong password it takes like a second or so to tell me it's wrong.
33
Upvotes
View all comments
Show parent comment
2
u/SlinkyAvenger Apr 09 '26
You don't know what you're talking about.
It's not a matter of checking the correct password versus the given one. The issue here is what happens once the hashes are to be compared to each other.
Let's say the correct password is
hunter2and a character comparison takes ~0.2ms. In a simple "loop through each character of the given password and check against the given character in the known good one, breaking with a failure if they don't match or continuing to the next character until they succeed" check, you'd see the following:aaaaaawould fail after ~0.2ms. The attacker has a baseline.baaaaawould also fail after ~0.2ms. The attacker has a good idea that ~0.2ms is the cost of a check.haaaaawould fail after ~0.4ms. The attacker can assume that at least the first character is correct.hbaaaawould fail after ~0.4ms. The attacker can continue to assume the first character is correcthuaaaawould fail after ~0.6ms. Now the attacker has a good sign that the first two characters arehu.So on and so forth. That way the brute force aspect is kept to a minimum because the attacker can glean information about its progress in figuring out the password limiting the amount of guesses they need to make.