DEV Community

Dita Larasati
Dita Larasati

Posted on • Edited on

4

Encode, Encrypt, and Hash

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

Encoding

Simply said, encoding process happens as transforming a number from base 10 (decimal) into base 2 (binary) format. Usually, the algorithms used is in the form of rigid pattern such as conversion table of ASCII, Unicode, Base-64, and URL-encoding.

Encoding technique is reversible. Anyone who knows the algorithm could decode the encoded data in order to retrieve the original data.

Encryption

Similar to encoding, encryption technique is reversible but more secure. Encryption can protect data from unauthorized person. A key is also needed to encrypt and decrypt the data, not only the algorithm.

This key-based encryption algorithms is classified into symmetric-key algorithm and asymmetric-key algorithm. As the naming, the symmetric means that the key for encryption and decryption is equal, and the asymmetric is different. In asymmetric algorithm, public key is a name for the key to encrypt and private key is for to decrypt.

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

Hashing

On the other hand, hashing can not do that kind of decode. Hashing is irreversible and more secure than encryption. 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


References:

  1. https://auth0.com/blog/hashing-passwords-one-way-road-to-security/
  2. https://auth0.com/blog/encoding-encryption-hashing/

Image of Quadratic

Free AI chart generator

Upload data, describe your vision, and get Python-powered, AI-generated charts instantly.

Try Quadratic free

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay