CPSA ยท Cryptography for testers
Encoding, encryption and hashing: what is the difference?
Why Base64 is not encryption, what hashing is for, and recognising each from sample values.
Key points
- Encoding (Base64, URL encoding, hex): changes the data format, needs no secret, anyone can reverse it.
- Encryption (AES, RSA): hides data, reversible only with the right key.
- Hashing (SHA-256, bcrypt): one-way, gives a fixed-length digest for checking integrity or storing passwords.
- A tester's clue: an 'encrypted' value that decodes without a key was only encoded.
Source: https://www.rfc-editor.org/rfc/rfc4648
Practice questions
Which of these transformations can be undone by anyone, with no secret at all?
- AES encryption with a random 256-bit key
- A SHA-256 hash of the data
- Base64 encoding of the data
- An HMAC-SHA256 tag over the data
Show answer
Answer: C. Base64 encoding of the data
Base64 is an encoding: it only changes representation and has no key. AES needs the key, SHA-256 is one-way, and an HMAC needs a secret key to create or check.
Which of these are one-way, meaning the original cannot be recovered from the output?
- A SHA-256 digest of a file
- A Base64 string
- A bcrypt password hash
- An AES-GCM ciphertext
- A URL percent-encoded string
Show answer
Answer: A. A SHA-256 digest of a file, C. A bcrypt password hash
Hash functions such as SHA-256 and bcrypt are one-way. Base64 and percent-encoding are reversible by anyone, and AES ciphertext is reversible with the key.
Passwords stored as unsalted MD5 hashes are safe because a hash cannot be reversed.
Show answer
Answer: False
False. A hash cannot be 'decrypted', but fast unsalted hashes are cracked by guessing: precomputed tables and GPU brute force find common passwords quickly. Passwords need a salted, deliberately slow hash such as bcrypt, scrypt or Argon2.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
