Crypto You Actually Need as a Developer

Hashing vs encryption, how to store passwords without regret, what TLS gives you, and the one rule that keeps you out of trouble — don't roll your own.

· 2 min read · intermediate

You don't need to be a cryptographer, but a few clear distinctions prevent the mistakes that cause real breaches.

Hashing is not encryption

They're often confused; they solve different problems.

EncryptionHashing
Reversible?Yes, with the keyNo, one-way
Purposeconfidentialityintegrity / verification
ExampleTLS protecting trafficverifying a download, storing passwords

Encryption scrambles data so it can be recovered with a key. Hashing maps data to a fixed-size fingerprint that can't be reversed — you can only check whether something produces the same hash.

Storing passwords

Never store passwords, and never "encrypt" them (encryption is reversible — a leaked key exposes them all). Instead, store a slow, salted password hash:

python
# use a purpose-built password hash
from argon2 import PasswordHasher
ph = PasswordHasher()
stored = ph.hash(password)          # includes a random salt automatically
ph.verify(stored, attempt)          # checks a login

Three properties matter:

  • Salt — a random value per password, so identical passwords hash differently and precomputed ("rainbow") tables are useless. Modern hashers add it for you.
  • Slow — Argon2, bcrypt or scrypt are deliberately expensive, so brute-forcing a leak is painful. Never use fast hashes (MD5, SHA-256) for passwords.
  • Verify, don't decrypt — you compare hashes; you never recover the original.

What TLS actually gives you

TLS (the S in HTTPS) provides three things at once: confidentiality (eavesdroppers can't read it), integrity (tampering is detected), and authentication (the certificate proves you're talking to the real server). Inspect a server's certificate chain:

bash
openssl s_client -connect example.com:443 -servername example.com </dev/null

Symmetric vs asymmetric, briefly

  • Symmetric (AES): one shared key encrypts and decrypts. Fast; the challenge is sharing the key.
  • Asymmetric (RSA, elliptic curve): a public key encrypts / verifies, a private key decrypts / signs. Solves key exchange, but slow.

Real systems combine them: asymmetric crypto to agree on a key, then fast symmetric crypto for the bulk data. That's exactly what TLS does.

Takeaways

  • Encryption is reversible (confidentiality); hashing is one-way (integrity/verification) — don't mix them up.
  • Store passwords as slow, salted hashes (Argon2/bcrypt/scrypt), never encrypted, never with fast hashes.
  • TLS delivers confidentiality, integrity and authentication together.
  • Combine asymmetric (key exchange) with symmetric (bulk) — and never roll your own crypto; use vetted libraries.

Related

Security intermediate

The Web Vulnerabilities Worth Knowing

The handful of classic web bugs behind most real breaches — injection, XSS, broken access control — explained with the one-line principle that prevents each.

· 2 min read
Security beginner

Setting Up a Safe Home Security Lab

Build an isolated playground of virtual machines where you can break things, run malware safely and practise attacks — with zero risk to the real world.

· 2 min read