Cryptography
AvailableCryptographyIntermediate
Encoding, hashing and encryption look alike but do very different jobs. Watch each one transform the same message.
Run real SHA-256 and AES-GCM operations from your browser's Web Crypto API on text you type, generate keys safely and see why passwords need a slow, salted hash instead of plain SHA-256.
- Encoding changes the format
- UTF-8 turns text into bytes; Base64 turns bytes into letters that survive email and URLs. Anyone can reverse both. There is no secret involved.
- Hashing makes a fingerprint
- SHA-256 turns any input into a 256-bit digest. The same input always gives the same digest, a tiny change gives a completely different one, and it can't be reversed into the input.
- Encryption keeps a secret
- AES-GCM scrambles a message with a key and a fresh random IV. Only someone with the key can decrypt it, and any change to the ciphertext is detected.
- Keys here and keys in production
- In this lab a key exists only in this tab's memory and disappears when you leave. Real systems keep keys in a key management service or hardware module, control who can use them, and rotate them.
Plain SHA-256 is fast by design, which is exactly why it must never be used on its own to store passwords.
What you will learn
- Explain the difference between encoding, hashing and encryption.
- Describe what a SHA-256 digest guarantees, and what it doesn't.
- Encrypt and decrypt with AES-GCM, and understand why every message needs a fresh IV.
- Know why passwords need salts and slow hashing functions.
0 of 4 scenarios explored
0 of 4 scenarios explored
Your progress in this lab
Explore every scenario below to complete the lab. Opening the page or switching steps doesn't count.
- Decode Base64 back to text, with no keyNot yet
- Hash the same message twice and compare the digestsNot yet
- Encrypt a message and decrypt it with the same keyNot yet
- Change one bit of a ciphertext and see decryption refuse itNot yet
Next: the guided challenge
Protect the Secret puts what you practised here to work in a short scenario.
Start Protect the SecretGuided challenge
- AvailableIntermediate
Protect the Secret
Choose between hashing and encryption for a series of real-world needs, and justify each choice.