DEV Community

Elvin Seyidov
Elvin Seyidov

Posted on • Edited on

A Deep Cybersecurity View of Hashing

When I first started learning cybersecurity, I thought hashing was just a simple one-way function that turns data into a fixed-length value. But later I realized that real systems use hashing in many deeper and more complex ways—password storage, integrity checks, digital signatures, HMAC, KDFs like PBKDF2 and Argon2, salting, peppering, and protection against attacks such as rainbow tables or brute force.

In this article, I explain hashing from both the beginner perspective and the real-world cybersecurity perspective, showing how all these pieces fit together into a complete security system.


Hashing converts data into a fixed-length value using a one-way mathematical function that cannot be reversed.
It is used to verify integrity, protect passwords, and ensure security without ever exposing the original data.

  • Message digest

The result produced by a hash function.
It’s a fixed-length “fingerprint” of the input data.

  • Collision resistance

A property that makes it hard to find two inputs with the same hash.
Good hash functions make collisions practically impossible.

  • MD5

An old hashing algorithm that is now broken.
Collisions are easy to create, so it should never be used for security.

  • SHA1

A once-popular hashing algorithm that is now considered weak.
Attackers can generate collisions with modern hardware.

  • SHA-2 (SHA-256, SHA-512)

A very strong and secure family of hash algorithms.
Widely used today for passwords, signatures, and certificates.

  • SHA-256

A strong 256-bit hash function.
Think of it like a solid metal security door.

  • SHA-512

Same family as SHA-256 but with a longer 512-bit output.
Like the same metal door, but thicker and even stronger.

  • SHA-3

A newer hashing standard with a completely different design.
Considered very secure and resistant to modern attacks.

  • Salt

A random value added to a password before hashing.
It prevents attackers from using rainbow tables.

  • Pepper

A secret value stored separately from the database.
Even if the database is stolen, the pepper adds extra protection.

  • Rainbow Tables

Huge pre-computed lists of hashes and their matching inputs.
Adding a salt completely destroys the effectiveness of rainbow tables.

  • bcrypt

A slow hashing algorithm with an automatic salt.
Still very strong and commonly used for password storage.

  • Argon2

Next-generation hashing algorithm with memory-hard design.
Very difficult for GPUs or ASIC machines to crack.


  • Key Derivation Functions (KDFs)

A KDF (Key Derivation Function) is a cryptographic algorithm used to take a weak secret (like a password) and turn it into a strong, secure cryptographic key.

  • KDF2

KDF2 is a standardized Key Derivation Function used in cryptography. Human passwords are weak, short, predictable. KDF2 transforms them into long, random-like keys that are safe for encryption.

Simple explanation:

  • It takes an input (password or shared secret)
  • Passes it through a hash function many times
  • Produces a strong cryptographic key Human passwords are weak, short, predictable. KDF2 transforms them into long, random-like keys that are safe for encryption.

  • PBKDF2 (Password-Based Key Derivation Function 2)

PBKDF2 is one of the most widely used KDFs today (in Django, AWS, WPA2 WiFi, etc.).

What it does:

  • Takes a password
  • Adds a salt
  • Repeats hashing thousands or millions of times
  • Produces a secure key

Why it is secure:
The repeated hashing makes it slow on purpose, making brute-force attacks extremely expensive.
Use cases:

  • Storing password hashes
  • Deriving encryption keys
  • Protecting user authentication data

  • HMAC (Hash-Based Message Authentication Code)

What it is:
HMAC is a cryptographic method that uses:

  • A hash function (SHA-256, SHA-512, etc.)
  • A secret key

to produce a secure code that proves:

  1. The message is genuine (authentication)
  2. The message was not changed (integrity)

Simple explanation:
HMAC = hash(message + secret key)

An attacker cannot forge the HMAC because they do not know the secret key.

Why it’s used:

  • Protects API requests (e.g., AWS S3 signatures)
  • Protects cookies and session tokens
  • Provides integrity and authenticity in network protocols

Difference from hashing:
Hashing alone does NOT require a key → anyone can recompute it.
HMAC uses a secret key, so only someone with that key can produce the correct code.


Hashing is everywhere in cybersecurity, from passwords to digital signatures. Once you understand how it works and why it’s designed this way, many other security concepts start to make sense.

Top comments (0)