Hash Functions and Digital Signatures—two core topics in Information Security that work closely together to ensure data integrity, authenticity, and non-repudiation.
🔑 Hash Functions
🧠 What is a Hash Function?
A hash function is a mathematical algorithm that takes input data of any size and produces a fixed-size output (called a hash or digest).
🔍 Key Properties of Good Hash Functions:
| Property |
Explanation |
| Deterministic |
Same input always gives the same output |
| Fast |
Quickly computes the hash |
| Irreversible (One-way) |
You can't get the original input from the hash |
| Collision-resistant |
Two different inputs should not produce the same hash |
| Avalanche effect |
Small change in input → drastically different hash |
🔧 Common Hash Algorithms:
- MD5 – obsolete (not secure)
- SHA-1 – weak, not recommended
- SHA-256 / SHA-3 – widely used, strong security
✅ Uses of Hash Functions:
- Password storage (hashed, not plain text)
- Data integrity (detect tampering)
- Digital signatures (paired with encryption)
- File integrity checks (e.g., software downloads)
✍️ Digital Signatures
🧠 What is a Digital Signature?
A digital signature is a cryptographic technique that verifies:
- Authenticity – who sent the message
- Integrity – the message wasn’t altered
- Non-repudiation – the sender can't deny sending it
🔄 How Digital Signatures Work (Simplified):
- Sender creates a hash of the message.
- Sender encrypts the hash using their private key → this is the digital signature.
- Sender sends the message + signature.
🛡️ On the receiver’s side:
- Receiver decrypts the signature using the sender’s public key → gets the original hash.
- Receiver hashes the message themselves.
- If both hashes match → ✅ message is authentic and untampered.
🔧 Algorithms Used:
- RSA
- DSA (Digital Signature Algorithm)
- ECDSA (Elliptic Curve DSA)
📦 Real-World Use Cases:
- Email signing (PGP, S/MIME)
- Software distribution (signed executables)
- Digital certificates (SSL/TLS)
- Blockchain transactions
🔁 Relationship Between Hash Functions & Digital Signatures:
| Hash Function |
Digital Signature |
| One-way, fixed-size output |
Uses hash of data + encryption |
| Ensures integrity |
Ensures authenticity, integrity, and non-repudiation |
| Fast and irreversible |
Based on asymmetric encryption |
| Example: SHA-256 |
Example: RSA with SHA-256 |
🧠 Analogy:
Think of a hash like a fingerprint of a file.
A digital signature is like a fingerprint that's been stamped with your unique seal (private key), proving it’s yours and hasn’t been altered.