Hashing is to map a great set to an (usually) substantially smaller set - e. g. all English words (there are a many of them) to English alphabet (only 26 capital + 26 small letters) by choosing the first letter of the word:
Peter -> P
Panama -> P
dog -> d
dust -> d
As you can see, it's not a 1-to-1 mapping, and from the hash you are not able unambiguously tell, which word was hashed. Nevertheless, it's useful, e. g. in card files:
(Of course, there are other requirements for a hash to be a cryptographic one.)
Encryption, on the other hand, is a 1-to-1 mapping between plain texts and encrypted ones, e. g. by replacing each letter in a word by the next one in the alphabet (and z
or Z
letters back to a
or A
):
Peter -> Qfufs
Panama -> Qbobnb
dog -> eph
dust -> evtu
(Of course, there are other requirements for a 1-to-1 mapping to be an encryption, end even more to label it as a good encryption.)