Cryptography › Module 1 › Lesson 1
What are Hash Functions?
Learn one-way digests, integrity checks, and why hashes are not encryption
Opening
A fingerprint, not a lockbox
Hashing is one of the most useful ideas in security—and one of the most misunderstood. People say “encrypted password” when they mean “hashed password.” Those are not the same. A hash is a one-way digest. You can verify data with it. You cannot (practically) reverse it to get the original.
1. What a Hash Function Does
A cryptographic hash function takes input of any size—a password, a file, a firmware image—and produces a fixed-length output called a digest. Good properties: • Deterministic — same input always yields the same hash • Avalanche effect — tiny input change → huge digest change • One-way — hard to find an input that produces a given digest • Collision resistant — hard to find two different inputs with the same digest
2. Hashing vs Encryption
Hashing
One-way. No key to “decrypt.” Used for integrity and password storage.
Encryption
Two-way with a key. Ciphertext can be turned back into plaintext if you have the key.
Hash a string with Pythonimport hashlib print(hashlib.sha256(b"cyberlium").hexdigest())
import hashlib print(hashlib.sha256(b"cyberlium").hexdigest())
Integrity first use case
Download a Linux ISO, compare the published SHA-256 to your local hash. If they differ, do not trust the file.
Knowledge Check
A cryptographic hash is best described as:
Multiple choice
Knowledge Check
True or False: Hashing and encryption are the same operation.
True or False
Knowledge Check
If one byte of a file changes, a good hash should:
Multiple choice