Can someone explain to me the concept of hashing versus the concept of encryption? [duplicate]

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 StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Nov 22 '18 at 14:55

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:

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