Complete Guide 5 min read

Why Does the Same Text Give a Different MD5 Hash? 6 Common Causes

Your MD5 hash does not match even though the text looks identical? Trailing newlines, spaces, letter case, line endings and encoding are the usual culprits.

md5 hash not matchingwhy md5 hash differentmd5 of string onlinemd5 trailing newlinemd5 hash generator text

The short answer

MD5 hashes bytes, not "text as you see it". If two inputs differ by even one invisible character, such as a newline at the end, a trailing space or a capital letter, the hashes will look completely unrelated. Paste exactly what you want to hash into the MD5 Hash Generator, click Generate Hashes, and compare. If the result still does not match, work through the six causes below.

A quick demonstration

Every row in this table looks like "hello" to a human. The MD5 values were computed for exactly the bytes described.

InputMD5
hello5d41402abc4b2a76b9719d911017c592
Hello (capital H)8b1a9953c4611296a827abf8c47804d7
hello followed by a newlineb1946ac92492d2347c6235b4d2611184
hello followed by a spacef814893777bcc2295fff05f00e508da6
a space followed by hello292a5af68d31c10e31ad449bd8f51263
hello followed by a Windows line ending (CR LF)af5597c29467a96523a70787c319f4db

This is by design. A hash function is supposed to change completely when the input changes slightly, so you cannot tell from two hashes how "close" the inputs were. You can only tell whether they were identical.

Cause 1: A trailing newline

This is the most common cause by far. Many command-line habits add a line break without you noticing:

  • echo hello | md5sum on Linux hashes "hello" plus a newline, giving b1946ac9.... Use echo -n hello | md5sum or printf 'hello' | md5sum to get 5d41402a....
  • Saving text in an editor usually adds a newline at the end of the file, so md5sum file.txt will not match the hash of the same words typed into a box.
  • Copying a line from a terminal or spreadsheet can carry the line break with it.

In the Lazyblink tool, a newline you paste is part of the input. If you pressed Enter after typing, delete it and generate again.

Cause 2: Spaces at the start or end

Leading and trailing spaces are easy to pick up when you copy from a web page, a PDF or an email. The tool hashes what is in the box, including those spaces; it does not trim them for you. Click at the end of the text and press Backspace to check, or retype the value.

Cause 3: Letter case

Hello and hello are different bytes, so they have different hashes. Hex output is a separate question: 5D41402A... and 5d41402a... are the same hash written in upper and lower case. Lazyblink shows lowercase hex. If a system gives you uppercase, compare them case-insensitively, or convert one with the Case Converter before comparing.

Cause 4: Line endings in multi-line text

Windows traditionally ends lines with two characters (carriage return and line feed, CR LF), while Linux and macOS use one (LF). The same three-line address typed on two computers can therefore hash differently. If you are comparing multi-line text across systems, make sure both sides use the same line endings, or hash a single-line version.

Cause 5: Character encoding and look-alike characters

The Lazyblink tool encodes text as UTF-8 before hashing, which is what most modern systems do. Problems appear when the other side uses a different encoding, or when characters that look the same are actually different:

  • Accented letters. "café" can be stored as one character for "é" or as "e" plus a combining accent. They look identical but are different bytes.
  • Smart quotes and dashes. Word processors replace straight quotes with curly ones and hyphens with en dashes.
  • Non-breaking spaces. Copying from web pages can bring in a non-breaking space instead of a normal one.
  • Zero-width characters. Some apps insert invisible characters that you cannot see at all.

If you suspect this, retype the text by hand in a plain text box instead of pasting it.

Cause 6: You are comparing different algorithms

An MD5 hash is always 32 hexadecimal characters. If the value you were given is 40 characters it is SHA-1, 64 characters is SHA-256, and 128 characters is SHA-512. The Lazyblink tool shows MD5, SHA-1, SHA-256, SHA-384 and SHA-512 together, so check which row matches the length of the hash you have.

Length in hex charactersAlgorithm
32MD5
40SHA-1
64SHA-256
96SHA-384
128SHA-512

How to compare two hashes reliably

  • Paste the exact text into the MD5 generator and click Generate Hashes.
  • Hover over the MD5 row and click Copy.
  • Paste both hashes into the Text Diff Checker on separate lines, or compare the first and last six characters by eye.
  • If they differ, check for a newline, spaces and case first, because those explain most mismatches.
  • What MD5 is still fine for, and what it is not

    MD5 is fast and its output is short, which makes it convenient for non-security jobs:

    • Checking that a string or record has not changed between two systems.
    • Creating cache keys or de-duplicating identical values.
    • Matching a published MD5 value when that is the only one a source provides.

    It is not suitable where someone might deliberately create a collision. RFC 6151, the IETF's updated security considerations for MD5, says it is "no longer acceptable where collision resistance is required such as digital signatures". It is also a poor choice for passwords, because fast hashes can be guessed at very high speed. For passwords, use a slow password hashing algorithm such as bcrypt, scrypt or Argon2 on the server. For file integrity, prefer SHA-256; the guide to verifying a SHA-256 checksum explains how.

    If you want the background on what each algorithm does, read MD5, SHA-1 and SHA-256 explained.

    Privacy note

    The hashes are computed in your browser, and the text you type is not sent anywhere. Even so, avoid pasting real passwords into any online tool. Hashing a password yourself does not make it safe to store or share, for the reasons above.

    Summary

    • MD5 hashes exact bytes, so invisible differences change the result completely.
    • Check for a trailing newline first, then spaces, case and line endings.
    • Paste rather than retype only when you are sure the source is clean.
    • A 32-character hash is MD5; longer ones are SHA variants.
    • Use MD5 for quick change detection, not for passwords or signatures.

    Frequently asked questions

    Why is my MD5 hash different from the one I expected?

    Almost always because the input is not byte-for-byte identical. A trailing newline, an extra space, different letter case, Windows line endings or a different character encoding all change the hash completely.

    What is the MD5 hash of hello?

    The MD5 of the five lowercase letters hello, with nothing before or after, is 5d41402abc4b2a76b9719d911017c592. Hello with a capital H gives 8b1a9953c4611296a827abf8c47804d7.

    Why does echo hello piped to md5sum give a different hash?

    echo adds a newline at the end, so you are hashing hello followed by a line break, which gives b1946ac92492d2347c6235b4d2611184. Use echo -n or printf to hash the text without the newline.

    Is MD5 safe for storing passwords?

    No. RFC 6151 says MD5 is no longer acceptable where collision resistance is required, and fast hashes like MD5 are unsuitable for passwords. Use a dedicated password hashing algorithm such as bcrypt, scrypt or Argon2.

    Try this tool on Lazyblink

    Put this guide into practice with our free online tool — no signup required.

    Open tool