Can one tell if a password guess was close by the hash result?

No, you cannot determine how close you guessed looking at the hash. A hash function is designed with this in mind: one single changed bit on the input must change a lot of bits on the output. Its called Avalanche Effect.

Bellow are SHA1 hashes for some of your example passwords:

cbfdac6008f9cab4083784cbd1874f76618d2a97 - password123

b2e98ad6f6eb8508dd6a14cfa704bad7f05f6fb1 - Password123

2b4bfcc447c3c8726d26c22927a68f511d5e01cc - password124

115b55dcc1cd9a0dfdd60c120e83eaf658c45fc6 - right horse battery staple

abf7aad6438836dbe526aa231abde2d0eef74d42 - correct horse battery staple

A single bit change will completely change the hashing result. In fact, in an ideal case for every bit of input change every bit of output will be changed with a 50% probability.


No, thanks to avalanche effect, even a single bit change in input should a create a significant large difference in the output.

Also talking about hashing functions like md5 or others... Given any input size the output size will not change. In md5 if your input size is 2 bits or 2000 bits, your output will always be 32 digit in alpha numeric ( hexadecimal format). So it makes almost impossible for the normal user to guess the input size even if he has hashed md5 output, guessing password is way beyond the scope for normal user, still there are ways with high end parallel computing by applying algorithms and lots of permutations and combinations to figure out one of the possible input if you have the hashed code...!

md5 Output:
password123  = 482c811da5d5b4bc6d497ffa98491e38
Password123  = 42f749ade7f9e195bf475f37a44cafcb
password1234 = bdc87b9c894da5168059e00ebffb9077

Above results shows the avalanche effect.


To add one additional element to the answers above - the whole point of a hash function is to not shed the sort of information in the question - if you could determine anything about the similarity of the inputs form comparing the outputs, that represents a failure of the hash function.

It's not just that hash functions perform some job and, incidentally, you can't figure out anything about the inputs, the job of the hash function is to give you zero information about the inputs, and if you could find out something about the inputs by comparing two outputs, then that would violate that principle.