Guides Security and developers

Base64, URL Encoding and Hashing: What Is the Difference?

Three ways of transforming data that are often confused, with examples of what each does, when to use it and what it cannot do.

Base64, URL encoding and hashing all turn readable data into strings of odd-looking characters, so they are easy to confuse. They do completely different jobs. Base64 and URL encoding are reversible ways of packaging data so it travels safely; hashing is a one-way fingerprint that cannot be turned back into the original. Mixing them up leads to real problems, from broken links to passwords that are not protected at all.

This guide explains each technique with worked examples, shows when to use which and clears up the most common misunderstanding: that encoding is a form of security.

Encoding versus encryption versus hashing

  • Encoding changes the format of data so it can be stored or transmitted safely. Anyone can reverse it; there is no key or secret.
  • Encryption scrambles data with a key so that only someone with the right key can read it.
  • Hashing produces a fixed-length fingerprint of data. It cannot be reversed, and the same input always gives the same fingerprint.

Base64 and URL encoding are encoding. Neither hides anything.

Base64: binary data as text

Many systems, such as email, JSON and some web forms, were designed to carry text. Images, PDFs and other binary files contain bytes that these systems might corrupt. Base64 solves this by representing any bytes using only 64 safe characters: A to Z, a to z, 0 to 9, plus + and /, with = used for padding.

How it works: Base64 takes 3 bytes, which is 24 bits, and splits them into four groups of 6 bits. Each 6-bit group, with a value from 0 to 63, becomes one character.

Examples:

TextBase64
HiSGk=
Hi!SGkh
HelloSGVsbG8=
Pakistan ZindabadUGFraXN0YW4gWmluZGFiYWQ=

The = signs appear when the input length is not a multiple of 3. Because every 3 bytes become 4 characters, Base64 makes data about 33 per cent larger: a 3 MB file becomes about 4 MB of Base64 text.

Common uses:

  • email attachments, which are sent as Base64 inside the message
  • small images embedded directly in web pages or CSS as data URLs, which you can create with Image to Base64
  • binary values inside JSON, such as signatures or small files
  • the header and body sections of JSON Web Tokens, which use a URL-safe variant

The Base64 Encoder and Base64 Decoder convert in both directions. Remember that anyone can decode Base64 in seconds, so never use it to "hide" passwords or private data.

URL encoding: safe characters in web addresses

Web addresses may contain only a limited set of characters. Spaces, many symbols and all non-English letters must be converted into a percent sign followed by two hexadecimal digits for each byte. This is called URL encoding or percent-encoding.

Examples:

OriginalURL encoded
price list 2026.pdfprice%20list%202026.pdf
cafécaf%C3%A9
a&b=ca%26b%3Dc
سلام%D8%B3%D9%84%D8%A7%D9%85

Characters outside basic English are first converted to UTF-8 bytes, and each byte is encoded, which is why the Urdu word سلام, four letters, becomes eight percent codes.

Why it matters: characters such as &, = and ? have special meanings in a URL. If a search term contains an ampersand, as in "lawn suits & dupatta", it must be encoded as lawn%20suits%20%26%20dupatta, or the ampersand will be read as the start of a new parameter and the search will break.

You may also see a plus sign used for spaces. That comes from the older form-encoding standard used when web forms are submitted; in that context, "red shoes" becomes red+shoes. The URL Encoder and URL Decoder handle both.

Hashing: a fingerprint for data

A hash function takes any input, from one word to a large video, and produces a fixed-length output called a hash or digest. Good hash functions have three key properties:

  1. Deterministic: the same input always gives the same hash.
  2. One-way: you cannot work back from the hash to the input.
  3. Avalanche effect: a tiny change to the input produces a completely different hash.

Example with SHA-256:

  • hello gives 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
  • Hello, with a capital H, gives 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

One changed letter produces a hash with nothing in common with the first. SHA-256 hashes are always 64 hexadecimal characters, whatever the input size.

Common uses:

  • Checking downloads. Software publishers list the hash of their files. If the hash of your download matches, the file was not corrupted or tampered with.
  • Spotting duplicates. Identical files have identical hashes, which makes it easy to find copies.
  • Version control and blockchains use hashes to identify content and detect changes.
  • Password storage, when done with special slow algorithms, as explained below.

The Hash Generator computes several algorithms at once, and the SHA-256 Generator focuses on the most widely recommended one.

MD5 and SHA-1: fine for checksums, not for security

MD5 and SHA-1 are older hash functions. Researchers have shown practical ways to create two different inputs with the same MD5 or SHA-1 hash, called collisions, so these algorithms must not be used where security depends on it, such as digital signatures or certificates. They are still acceptable for non-security tasks such as detecting accidental file corruption. For anything security-related, use SHA-256 or stronger. The MD5 Generator remains useful for matching older checksums.

Hashing passwords properly

Websites should never store passwords as plain text, but a fast hash such as SHA-256 on its own is not enough either. Fast hashes let attackers test billions of guesses per second against a stolen database, and identical passwords produce identical hashes. Proper password storage uses:

  • a slow, memory-hard algorithm designed for passwords, such as Argon2, bcrypt or scrypt
  • a unique random salt for each user, so identical passwords produce different stored values

If you build websites, use your framework's built-in password hashing functions rather than writing your own.

Which one do I need?

TaskUse
Put an image inside HTML, CSS or JSONBase64
Put a search term or file name in a linkURL encoding
Check that a download is intactHashing (SHA-256)
Store user passwords on a websitePassword hashing (Argon2, bcrypt)
Keep a message secretEncryption, not encoding or hashing

Checking a download's hash yourself

Software publishers often list a SHA-256 checksum beside each download. To compare it with your copy, you do not need extra software:

  • Windows: open Command Prompt in the download folder and run certutil -hashfile setup.zip SHA256, replacing setup.zip with your file name.
  • macOS and Linux: open Terminal and run shasum -a 256 setup.zip.

Compare the long string that appears with the one on the publisher's website. If even one character differs, the file is corrupted or has been altered, so delete it and download it again from the official source. Checking takes a minute and is worth doing for operating system images, banking software and anything downloaded from a mirror site.

Where you see these techniques every day

Your browser's address bar often shows a readable address while sending the encoded version behind the scenes. Email programs encode attachments in Base64, which you can see if you view a message's original source. App stores and update systems check hashes silently before installing software. Once you know the three techniques, you start noticing them everywhere.

Common mistakes

  • Treating Base64 as encryption. It hides nothing; anyone can decode it.
  • Encoding a URL twice. Double encoding turns %20 into %2520 and breaks links.
  • Comparing hashes of text with different line endings or spaces. Invisible differences change the hash completely.
  • Using MD5 for security. Choose SHA-256 or a dedicated password hash.

Privacy

All of these encoders, decoders and hash generators run in your browser. Text and files you process are never sent to this website, which matters when you are checking tokens, keys or private documents.

Free tools used in this guide