Bitzu

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

Single choice

Which of these transformations can be undone by anyone, with no secret at all?

  1. AES encryption with a random 256-bit key
  2. A SHA-256 hash of the data
  3. Base64 encoding of the data
  4. 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.

Select all that apply

Which of these are one-way, meaning the original cannot be recovered from the output?

  1. A SHA-256 digest of a file
  2. A Base64 string
  3. A bcrypt password hash
  4. An AES-GCM ciphertext
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More CPSA topics in this module