Get a Pentest and security assessment of your IT network.

Cyber Security

Decoding Base64

TL;DR

You’ve likely encountered Base64 encoding. It turns data into a string of letters and numbers, often used to embed images in emails or store binary data in text files. This guide shows you how to recognise it and decode it.

What is Base64?

Base64 isn’t encryption; it’s an encoding scheme. It represents binary data using a set of 64 characters (A-Z, a-z, 0-9, +, /). It’s designed to be easily transmitted over channels that only handle text.

How to Recognise Base64

  1. Character Set: Look for strings containing only letters (uppercase and lowercase), numbers, the plus (+) sign, and the forward slash (/).
  2. Padding: Base64 often ends with one or two equals (=) signs. These are padding characters used to ensure the encoded data is a multiple of 4 characters long.
  3. Length: Encoded strings are usually multiples of 4 in length.
  4. Context: Where did you find this string? Common places include:
    • Data URLs (e.g., in HTML <img src="data:image/png;base64,...">)
    • Email attachments (sometimes embedded directly into the email body).
    • Configuration files.

Decoding Base64

There are many ways to decode Base64, depending on your operating system and technical skill.

1. Using Online Tools

The easiest way for most users is an online decoder. Here’s how:

  1. Search Google for “Base64 decoder”.
  2. Copy the Base64 string you want to decode.
  3. Paste it into the decoder and click “Decode”.

2. Using Command Line (Linux/macOS)

If you’re comfortable with the command line, use base64:

base64 -d <your_base64_string>

For example:

echo "SGVsbG8gV29ybGQh" | base64 -d

This will output: Hello World!

3. Using Python

Python has a built-in Base64 module:

import base64

b64string = "SGVsbG8gV29ybGQh"
b64bytes = b64string.encode('ascii')
messagedecoded = base64.b64decode(b64bytes)
messages = messagedecoded.decode('ascii')
print(messages)

This will also output: Hello World!

4. Using PowerShell (Windows)

PowerShell can decode Base64 strings:

[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("SGVsbG8gV29ybGQh"))

This will output: Hello World!

What to do with the Decoded Data

The decoded data could be anything – text, an image, a file. Its format depends on what was originally encoded.

Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation