Cryptography Basics
hashing, encryption and signatures without the math
Cryptography is how we get confidentiality and integrity out of mathematics instead of trust. You do not need the math to use it well, but you do need to know which tool does which job.
Hashing: a fingerprint, one way
A hash function turns any input into a fixed-size fingerprint. The same input always gives the same output, a tiny change gives a completely different one, and you cannot work backwards from the fingerprint to the input. Uses: checking a downloaded file has not changed, and storing passwords. SHA-256 is a common modern hash; MD5 and SHA-1 are broken for security use.
Passwords need special care: use a slow, purpose-built password hash (such as Argon2, scrypt, bcrypt or PBKDF2) together with a unique random salt per user.[2] A fast hash like plain SHA-256 lets attackers try billions of guesses per second.
Symmetric encryption: one shared key
The same secret key locks and unlocks the data. It is fast, so it protects the bulk of data on disks and in network connections. AES is the standard choice. The hard part is getting the key to the other side safely.
Asymmetric encryption: a key pair
A public key can be shared with anyone; a private key is kept secret. Anyone can encrypt something with your public key, and only your private key can decrypt it. It is slower, so it is typically used to agree on a symmetric key, not to encrypt large files. RSA and elliptic-curve systems are common.
Digital signatures
Reverse the roles: you sign with your private key and anyone can check the signature with your public key. This proves who signed it and that it has not changed since. Signatures are what make software updates and website certificates trustworthy.
Encoding is not encryption
Base64, URL encoding and similar formats just change how data is written. Anyone can reverse them. If a "protected" value is only Base64, it is not protected.
Rules of thumb
- Never invent your own algorithm. Use well-reviewed libraries and current standards.[1]
- Protecting the keys matters more than the algorithm. A strong cipher with a leaked key protects nothing.
- Use the right tool: hash for fingerprints, symmetric for bulk data, asymmetric for key exchange and signatures.
Sources
Test yourself
My notes
Private — saved only on this device, never sent anywhere.