DEV Community 👩‍💻👨‍💻

Dita Larasati
Dita Larasati

Posted on • Updated on

Encode, Encrypt, and Hash

In general, the meaning of encode is to convert something into code. We usually do encoding for Personal Identifiable Information (PII) because it contains sensitive data such as password, card number, etc.

According to the ability to decode the encoded data, there is two types of encoding: encryption and hashing.

Encryption

When we encrypt something, we always can do the decryption. I would say this seems like when you put something into the box and lock it. Well, as long as you know the secret, you can unlock and get what's in the box.

Encryption usually is implemented to protect data from outsider but at the end of the day programmer needs to know the data. Encrypted data could be found in email such as verify account, forgot password, etc.

Below is an example functions to do encryption-decryption:
Image description

Hashing

On the other hand, hashing can not do that kind of decode. Once you hash something, you can not know what the "something" really is. Even though it literally hashes your data, I would say that you still could know what kind of thing the "something". Just imagine a criminal scene: you got potential suspects and blood of suspect in the crime scene. Here, the blood is the result of hash the potential suspect. By comparing the DNAs, we could know that the blood comes from the suspect.

Hashing usually is implemented for password. Although programmer who creates the program, programmer is not allowed to know user's password. A program must be designed to save user's password in the form of hashed password in database. None of way to decode it.

The following is example of hashing-comparing implementation:

hashing

comparing

Top comments (0)

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.