Cryptography is the maths that makes confidentiality and integrity possible. You don't need to implement algorithms — you need to know which tool solves which problem, and (just as important) the mistakes to avoid. The golden rule up front: never roll your own crypto — use vetted libraries.
Why cryptography?
It gives us three superpowers: hide data from eavesdroppers (encryption), detect tampering (hashing/signatures), and prove identity (certificates). Every "https", every stored password, every signed update relies on it.
Hashing
A hash is a one-way fingerprint of data — same input always gives the same fixed-length output, but you can't reverse it. It's for verifying integrity and storing passwords, not for encryption (you can't get the data back):
"albero" → SHA-256 → 2f3a… (64 hex chars)"albero1" → SHA-256 → 9c1b… (completely different)Same input → same hash. One char changed → totally different hash.One-way: you cannot compute the input from the hash.
Symmetric vs asymmetric
| Type | Keys | Used for |
|---|---|---|
| Symmetric (AES) | One shared secret key | Fast bulk encryption of data |
| Asymmetric (RSA/ECC) | A public + private key pair | Key exchange, digital signatures |
Asymmetric crypto solves the "how do two strangers agree on a secret?" problem: anyone can encrypt with your public key, but only your private key decrypts. In practice, systems combine both — asymmetric to exchange a key, then fast symmetric for the data.
HTTPS & TLS
TLS is what puts the "s" in https. When you connect, the server presents a certificate proving its identity (signed by a trusted authority), you agree on a shared key, and all traffic is encrypted from there. This defeats eavesdropping and tampering on the network:
Storing passwords
Never store passwords in plain text, and never with a plain hash. Use a slow, salted password hash built for the job — bcrypt, scrypt or argon2. The salt stops precomputed lookups; the slowness stops mass guessing:
import bcrypt from "bcrypt";// On signup — store the hash, never the passwordconst hash = await bcrypt.hash(password, 12); // 12 = work factor// On login — compare, don't decryptconst ok = await bcrypt.compare(attempt, hash);
Practice
Explain to yourself why a fast hash like SHA-256 is wrong for passwords but right for verifying a file download. Then look at how a login flow you use stores passwords (it should be bcrypt/argon2), and confirm the site uses HTTPS.
Key takeaways
- 01Never roll your own crypto — use vetted libraries.
- 02Hashing is a one-way fingerprint for integrity and password storage — not reversible.
- 03Symmetric (AES) is fast bulk encryption; asymmetric (RSA/ECC) handles key exchange & signatures.
- 04TLS/HTTPS uses certificates + a shared key to encrypt traffic — use it everywhere.
- 05Store passwords with a slow, salted hash (bcrypt/scrypt/argon2), and compare rather than decrypt.
