hexforge / guides / base64

GUIDE 01 / ENCODING

How to Identify Base64

Base64 has a recognizable shape, but looking compatible is not proof. A reliable decision combines syntax, length, padding, and the structure of the decoded bytes.

Start with four visible signals

Standard Base64 uses uppercase and lowercase letters, digits, +, and /. One or two = characters may appear at the end as padding. The encoded length is normally divisible by four. Base64URL replaces + and / with - and _, and often omits padding.

SignalUseful evidenceWhat it does not prove
Compatible alphabetThe string can be Base64Plain words and random tokens can also match
Length divisible by fourFits standard groupingShort strings may match by chance
Ends in = or ==Strong padding clueUnpadded Base64 is common
Decoded structureThe most useful validationCorrect output may be binary, not text

A reproducible CTF example

Consider this value:

ZmxhZ3tiYXNlNjRfaXNfZW5jb2Rpbmd9

It uses the expected alphabet and its length fits complete groups. Decoding once produces:

flag{base64_is_encoding}

The output is readable and matches a common flag structure, so the interpretation is well supported. Base64 is an encoding, not encryption: it uses no secret key and provides no confidentiality.

Validate the decoded bytes

  1. Look for readable text, JSON, a URL, a recognizable file header, or a flag pattern.
  2. If the output looks corrupted, inspect the bytes before assuming failure. Images and archives are not readable text.
  3. If the result resembles another encoding, record the first step and test the next layer separately.
  4. If padding fails, check whether the input is Base64URL and restore padding only when the length supports it.
Do not rely on the equals sign

JWT segments commonly use unpadded Base64URL. Conversely, a configuration value ending in = is not automatically Base64. Syntax and decoded structure must agree.

Common mistakes

Treating every unreadable result as failure

Decoding returns bytes. Those bytes should only be displayed as UTF-8 when the original data was text. A PNG, ZIP archive, compressed stream, or encrypted value will look unreadable in a text box even when decoding succeeded.

Decoding repeatedly without evidence

Record the input, operation, and output at every layer. Continue only when the result gains structure: clearer delimiters, a known header, valid JSON, or another well-supported encoding signal.

Deleting meaningful characters

Removing whitespace from wrapped Base64 is usually safe. Removing characters that belong to the alphabet is not. Keep an untouched copy before normalizing the candidate.

A stable workflow

  1. Preserve the original input.
  2. Check alphabet, length, and padding.
  3. Distinguish standard Base64 from Base64URL.
  4. Decode exactly once and identify the output type.
  5. Save the evidence before testing another layer.