Skip to main content
>_ supraj.dev
TOPIC SECURITY
Hashing vs Encryption one-way vs two-way
IN 10 SECONDS

Hashing is a one-way mathematical function that outputs a fixed-length string (like SHA256) and cannot be reversed. Encryption is a two-way function that can be reversed using a secret key.

GOTCHA Using weak hashing algorithms (like MD5 or SHA1) for passwords allows hackers to crack database hashes in seconds using rainbow tables.
HOW HASHING VS ENCRYPTION FLOWS
01 Hash check system hashes user password at login and compares the result to the stored database hash.
02 Encryption run encrypts database data (ciphertext) before writing to disk.
03 Decryption run reads ciphertext from disk, applying key to decrypt it back to plaintext.
POKE IT YOURSELF
echo -n "password" | sha256sum — generate a SHA256 hash of a string
gpg -c secrets.txt — encrypt a file symmetrically with a passphrase