r/AskComputerScience • • May 20 '25

why does password length affect strength if passwords are salt-hashed?

My understanding is that passwords are hashed into long, unpredictable strings via a one-way hash function. Why does the input length matter?

78 Upvotes

56 comments sorted by

View all comments

Show parent comment

1

u/Leverkaas2516 May 21 '25

If you don't know the salt value, it makes the list so big that "shorter passwords mean less guesses" still means eons of guessing.

1

u/UncleMeat11 May 21 '25

But you typically do know the salt value. The scenario here is an offline attack after the credentials database has been dumped. Salts are typically stored alongside the hashes.

1

u/Leverkaas2516 May 21 '25

Someone made that point in a different thread, yes. But we're not talking about a case of the salt being known. This thread starts with the claim "Because someone can generate a list of possible passwords, then run the same one-way hash function and see if they match. It's just guessing what the password might be. Shorter passwords mean less guesses until you get it right."

Just knowing the hash function to use doesn't make the problem tractable.

2

u/UncleMeat11 May 21 '25

But we're not talking about a case of the salt being known.

Why not? If we are talking about online attacks then the issue is rate limiting. If we are talking about offline attacks then it is always assumed that both the salt and hash are known.

1

u/Leverkaas2516 May 21 '25

What we are talking about is explaining all this to someone who doesn't know. In that way, VirtuteECanoscenza gave a good answer. MrColdboot gave one that can only be regarded as true if one already knows all the things that OP obviously does not know. "It's just guessing what the password might be" is false.

2

u/UncleMeat11 May 21 '25

"Salting makes this unfeasible" is providing the wrong information to people.

-1

u/Leverkaas2516 May 21 '25

It's been such a delight talking to you. You are probably a big hit at parties.

2

u/Samstercraft May 23 '25

the thing people say on reddit when they realize they're wrong

1

u/BarneyLaurance May 21 '25

> But we're not talking about a case of the salt being known.

You should always assume that if anyone knows the password hash then they also know the salt. That's the nature salt in cryptography.

If something similar to a salt is deliberately kept secret, even from systems or people that have access to the password hashing then we don't call it salt we call it pepper. Pepper can also be useful but is a lot less common than salt.

1

u/lurkerfox May 21 '25

Theres not been a single time ever that Ive had to crack a hash where the salt was unavailable. Its always stored with the hash if not part of the hash result itself.

1

u/Top-Story2654 May 22 '25

The salt value litterally doesn't matter. The algorithm will always use the correct salt even if you provide incorrect password input.
Salt only prevents precomputing the value and looking it up from a rainbow table.

Edit, not to mention, knowing the salt is also not helpful unless you have a rainbow table of that particular salt already precomputed.

1

u/[deleted] May 23 '25

If you don't know the salt value, it makes no difference whatsoever. The salt is basically always stored with the hash. Either you don't know the salt/hash and brute forcing will take as long as if it were unsalted, or you do know the salt/hash and you can brute force locally (you just can't precompute a rainbow table).

Maybe you are thinking of a pepper, which is like an extra salt but usually stored outside the database in a separate secret store?