Applied cryptography

Symmetric vs asymmetric, hashing vs encryption vs encoding, TLS, password storage (bcrypt/argon2 with salt). Confusing these three is an instant fail.

About 30 min read3-question knowledge check

The mental model

Three operations get confused constantly, and confusing them is the single fastest way to fail a security interview. The clean way to keep them apart is to ask what problem each one solves and whether it is reversible without a secret:

  • Encoding (Base64, URL-encoding, hex) is about format, not security. It transforms data so a channel can carry it — turning bytes into ASCII so they survive an email header. It is fully reversible by anyone, needs no key, and provides zero confidentiality. Base64 is not encryption; it is a costume, not a lock.
  • Hashing (SHA-256, bcrypt, Argon2) is a one-way fingerprint. It maps any input to a fixed-size digest that cannot be reversed to recover the input. There is no key and no "decrypt." You use it to verify (does this password match, has this file changed) without storing the original.
  • Encryption (AES, RSA, ChaCha20) is reversible with a secret. It scrambles data so only a holder of the key can recover it. This is the only one of the three that provides confidentiality, and it is defined by the key: no key, no decryption.

The analogy that sticks: encoding is translating a letter into Morse code (anyone with the chart reads it), hashing is a paper shredder (you can confirm two documents shredded identically but you cannot un-shred), encryption is a locked safe (only the key opens it). A candidate who says "I'll hash the credit card so we can decrypt it later" has confused all three — you cannot decrypt a hash, and a credit card you need to charge must be encrypted, not hashed.

Cryptography exists because we need to protect data on channels and storage we do not control. The internet is a hostile medium: every packet crosses networks run by strangers. Cryptography lets two parties who share a secret (or trust a public key) communicate confidentially and detect tampering across that hostile medium — and it lets a server verify a password without ever storing the password itself. Almost every other security control assumes crypto underneath: TLS, signed tokens, password storage, disk encryption, code signing.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision