CPSA ยท Web application assessment: injection, sessions and code
Recognising encoded and hashed values
Spotting Base64, hex, URL encoding and MD5/SHA hashes and what can be done with each.
Key points
- Encodings are reversible by anyone and give no secrecy.
- Base64: A-Z, a-z, 0-9, + and /, often = padding, length divisible by 4.
- Hex: 0-9 and a-f, two characters per byte. URL encoding: %XX such as %20.
- Hashes: one-way, fixed length; in hex MD5 is 32 characters, SHA-1 40, SHA-256 64.
- A hash cannot be decoded, only tested against guesses, feasible for weak or unsalted inputs.
- Decode encoded values; if editable, test tampering.
Source: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
Practice questions
Which encoding uses the characters A-Z, a-z, 0-9, + and /, and is often padded with = at the end?
- Hexadecimal
- URL encoding
- Base64
- ROT13
Show answer
Answer: C. Base64
That is the Base64 alphabet with its padding character. Hex has only 0-9 and a-f, URL encoding is built from %XX sequences, and ROT13 only shifts letters.
Which of these representations can be reversed by anyone, without a key or guessing?
- Base64 text
- Hex-encoded bytes
- URL-encoded string
- SHA-256 digest
- AES-encrypted blob
Show answer
Answer: A. Base64 text, B. Hex-encoded bytes, C. URL-encoded string
Base64, hex and URL encoding are public, keyless transformations. A SHA-256 digest is one-way and AES ciphertext needs the key.
True or false: a value that looks like random letters and digits, such as a Base64 string, is protected because attackers cannot read it.
Show answer
Answer: False
False. Base64 is only an encoding; anyone can decode it in seconds. Looking unreadable is not the same as being protected.
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.
