DEV Community

Shreehari Menon
Shreehari Menon

Posted on • Originally published at meetcyber.net on

Encryption vs Hashing vs Digital Signatures: Understanding the Core of Digital Security

A beginner-friendly guide to the three technologies protecting modern digital communication.

1. Introduction: The Developer’s Dilemma

A few years ago, a massive tech company suffered a devastating data breach. Cybercriminals broke into their backend servers and stole millions of user accounts. However, the real scandal was not the break-in itself; it was what the hackers found inside the database. The development team had “secured” the user passwords using encryption instead of hashing. When the hackers eventually found the decryption key hidden on another server, they instantly unlocked every single password in plain text.

This is a classic - and highly dangerous - mistake.

Earlier, we learned that cryptography is essentially a security toolbox designed to protect three things: Confidentiality (keeping secrets), Integrity (preventing tampering), and Authentication (proving identity). But a toolbox is only useful if you know exactly which tool to grab. You wouldn’t use a hammer to drive a tiny screw. Similarly, you should never use encryption to store a password.

Today, we are going to pull the three most critical tools out of the cryptographic toolbox: Encryption , Hashing , and Digital Signatures. By the end of this article, you will understand exactly how they differ, the intuition behind how they work mechanically, and precisely when you, as a developer, should use each one in a real-world system.

2. Tool 1: Encryption (The Two-Way Street)

Primary Goal: Confidentiality (Keeping secrets safe from prying eyes)

When most people outside of the tech industry hear the word “cryptography”, they are actually thinking solely of encryption. Encryption is the process of scrambling readable data (Plaintext) into an unreadable format (Ciphertext), with the specific and deliberate intention of unscrambling it later.

The most important thing to remember about encryption is that it is a two-way street. If you can encrypt data, there is a mathematical way to decrypt it, provided you possess the right key.

How it Works: The Lockbox Analogy

Imagine you have a highly confidential corporate document. You place this document inside a sturdy titanium lockbox and snap a padlock shut. You hand the box to a courier. The courier can carry the box across the country, on airplanes and trains, but they cannot read the document inside. When the box finally reaches its destination, the recipient uses a physical key to unlock the padlock and read the original document.

In digital terms:

  • The original document is the Plaintext.
  • The locked titanium box is the Ciphertext.
  • The physical key is the Cryptographic Key (usually a long string of digital bits).

When Developers Use Encryption

You use encryption whenever data needs to travel securely or be stored safely, and a legitimate user or system needs to read that original data later. Engineers generally divide this into two categories:

  1. Data in Transit: When information is moving across a network. For example, when you browse a website using HTTPS, the data flowing between your browser and the server is encrypted. Your Internet Service Provider can see that you are connected to a bank, but they cannot see your account balance or passwords.
  2. Data at Rest: When information is sitting still on a storage device. For example, BitLocker on Windows or FileVault on Mac encrypts your laptop’s entire hard drive. If a thief steals your laptop, they cannot extract your files without the decryption password.


Encryption is a reversible process. What goes in can be perfectly recovered with the correct key.

3. Tool 2: Hashing (The One-Way Street)

Primary Goal: Integrity (Proving data hasn’t changed)

If encryption is a reversible lockbox, hashing is a paper shredder.

Hashing is a mathematical algorithm that takes an input of any size - a single word, a high-resolution photograph, or a 100-gigabyte database file - and crushes it down into a fixed-length string of random-looking characters. This output is called a Hash or a Digest.

Crucially, hashing is a one-way street. Once data is hashed, it is mathematically impossible to reverse the process and get the original data back. Just as you cannot realistically reassemble a document once it has been thoroughly shredded, you cannot reverse a hash to recover the original data.

The Magic of the “Avalanche Effect”

A high-quality hashing algorithm (like SHA-256) has two vital properties:

  1. Deterministic: If you hash the word “Apple”, you will get the exact same 64-character hash every single time.
  2. Highly Sensitive (The Avalanche Effect): If you hash a 500-page book, and then change a single comma on page 240, the resulting hash of the entire book will completely and radically change. The new hash will look absolutely nothing like the old hash.

Why Developers Use Hashing

Because hashes act as unique, highly sensitive digital fingerprints, they are perfect for two specific jobs:

  1. File Verification: When you download a large software update, the developer publicly posts the “Hash” of the legitimate file on their website. Your computer downloads the file, hashes it locally, and compares the two hashes. If they match perfectly, you have mathematical proof that the file wasn’t corrupted during the download, nor was a virus secretly injected into it by a hacker.
  2. Password Storage (The Golden Rule): Websites must never store your actual password. Instead, when you create an account, the server hashes your password and stores only the hash. When you log in tomorrow, the server hashes whatever you type into the login box and compares it to the stored hash. If they match, you are granted access.


Hashing creates a unique, fixed-size fingerprint of data. It is inherently irreversible.

4. Tool 3: Digital Signatures (The Seal of Authenticity)

Primary Goals: Authentication (Proving Identity) and Non-Repudiation (You can’t deny sending it).

In the physical world, we use pen-and-ink signatures and official notary stamps to prove that a contract is legitimate and that a specific person agreed to the terms. In the digital world, a scanned image of your signature is completely useless - it can be copy-pasted onto a fake document in seconds.

We need a mathematically unbreakable proof of identity. We achieve this by cleverly combining Asymmetric Encryption (which utilizes a Public and a Private key pair) and Hashing.

Note: We will dive deep into exactly how Public/Private keys work mathematically later on. For now, just know that the Private Key is kept absolutely secret by the sender, and the Public Key is shared freely with everyone in the world.

How it Works: The Digital Wax Seal

Imagine Alice wants to send a legally binding contract to Bob to buy a house. She needs to prove to Bob that she genuinely sent it, and she needs to guarantee that nobody altered the purchase price in transit.

  1. The Hash: Alice’s computer first creates a Hash (a digital fingerprint) of the contract.
  2. The Signature: Alice’s computer then encrypts only that Hash using her secret Private Key. This encrypted hash is her Digital Signature. She attaches this signature to the bottom of the contract and sends the whole package to Bob.
  3. The Verification: Bob receives the contract. His computer performs two distinct actions:
  • It creates its own fresh Hash of the contract document.
  • It decrypts Alice’s attached signature using Alice’s freely available Public Key. Doing this reveals the original Hash that Alice made.
  1. The Match: Bob’s computer compares the two hashes. If they match exactly, the signature is 100% valid!

Because only Alice possesses her Private Key, only Alice could have created that specific signature. This provides Non-Repudiation - Alice cannot claim later, “I didn’t sign that, I was hacked!” Furthermore, if a hacker intercepted the contract and changed the purchase price from $300,000 to $100,000, the hashes would no longer match, and the signature would instantly flash as invalid.

When Developers Use Digital Signatures

  • Software Updates: Your iPhone will only install operating system updates that are digitally signed by Apple’s private key. This strictly prevents hackers from tricking your phone into installing fake, malicious software.
  • Cryptocurrency & Web3: In blockchain networks like Bitcoin, digital signatures are the core mechanism that proves you are the true owner of a digital wallet and that you authorized a transfer of funds.


Digital Signatures use Hashing for integrity and Private Keys for identity, proving who sent a message and that it remains unaltered.

5. The Grand Scenario: Putting it All Together

To solidify these concepts, let’s look at a real-world scenario where a software developer must use all three tools simultaneously to build a secure system.

Imagine Alice (a CEO) is sending a highly sensitive corporate acquisition document to Bob (her lead lawyer) over the internet.

  1. Integrity: First, Alice’s software runs the document through a Hashing algorithm. This creates a fingerprint to ensure that not a single word of the acquisition terms can be altered during transit.
  2. Authentication: Next, Alice’s software takes that Hash and locks it with her Private Key, creating a Digital Signature. Bob now has undeniable proof that Alice - authorized this document.
  3. Confidentiality: Finally, Alice’s software takes the document and the signature, puts them together, and Encrypts the entire package before sending it. Now, if corporate spies intercept the data as it travels across the internet, they will see nothing but scrambled noise.

By combining the right tools for the right jobs, Alice and Bob have achieved absolute cryptographic security.

Summary: The Developer’s Cheat Sheet

What’s Next?

You now know the vital differences between scrambling data to hide it (Encryption) and crushing data to fingerprint it (Hashing). You also know that you should never, ever use encryption to store a password.

However, a major question remains. Under the umbrella of “Encryption”, there is a massive historical divide. How exactly do those “Keys” work? How can two computers that have never physically met securely agree on a secret key over a public, crowded, and hostile network like the internet?

In the upcoming articles , we will crack open the mechanics of modern communication. We will discover the brilliant mathematics that make the modern internet possible - and learn exactly why upcoming quantum computers threaten to tear it all down.


Top comments (0)