This question already has an answer here:

I'm a bit confused over the difference between hashing and encryption. Could someone help explain this to me in simple and concise, yet comprehensive layman's terms?

I'm not asking for any specifics in how they work, but rather how the essential concept of each work in layman's terms


marked as duplicate by Richie Frame, Ella Rose, user61539, Maarten Bodewes encryption Nov 22 '18 at 14:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The important difference is that encryption is intended to be undone, hashing isn't. Let's say I have a secret password called "pass001." If encrypted, pass001 would be scrambled with a key to be something unrecognizable like "a8d89sI." Using the exact same key, "a8d89sI" can be reverted back to pass001. Hashing scrambles the secret password in much the same way, but there is no key involved and there is generally no way to turn the computed hash back into "pass001." Why might this be useful? Assume you stored password hashes in your database. If a hacker were to steal the contents, then he would be left with hashes that he can't do anything with. Not even the owner of the database can see the original password. When a user logs in, the password they enter is hashed on the spot and this hash is compared to the hash stored in the database to check if they put in the right password. If they did, both the calculated hashes should be the same. Hashes are used for many things, but in this case, it's just an extra layer of security.


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:

enter image description here

(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.)


Not the answer you're looking for? Browse other questions tagged or ask your own question.