0

There appears to be an inconsistency (or unpublished protocol) in many online hash generators when formulating a hash from an uploaded text file, versus strictly hashing the contents of a file. This issue appears to be unrelated to the name of the file, yet can be consistently replicated.

For example, hashing the following (by copy-and-paste at http://onlinemd5.com/)...

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

... produces an MD5 hash of: A5E90C16BEB53BB93468496EAF2E0AC4.

Yet if one copies the above into a text file, then uploads the file, the MD5 hash produced is: 8F18B10192372D8523558CF65DB2B1B2, regardless of the name of the file.

In addition to the above site, this can reproduced at "passwordsgenerator.net/md5-hash-generator/" (copy-paste) and "md5file.com/calculator" (file upload), and is consistent among MD5, SHA-1, and SHA-256.

This implies that there are either unseen characters that are consistently being hashed within the file upload (independent of the filename) that are messing with the hash, or the algorithms are adding/subtracting characters upon file import (unlikely).

Why are these hashes coming out different?

I'm on a Windows machine, using basic notepad for file creation. Please excuse the "quote" links above; I do not maintain an appropriate reputation for multiple links in a post.

4

A5E90C16BEB53BB93468496EAF2E0AC4 is the MD5 hash of that text with Unix-style line endings (LF).

8F18B10192372D8523558CF65DB2B1B2 is the MD5 hash of that text with Windows-style line endings (CRLF).

Since you're using Notepad on Windows, I'm guessing the first site is converting the line endings to Unix-style before hashing the text.

0

Without being able to look at the code behind the website I likely suspect something very simple is going on.

When you enter the text into the input box, the backend code is treating this as a simple string. Each programming language has it's own encoding such as ASCII or UTF-8.

In the file, you are saving it with an encoding, which the website's code seems to take into account. You can see this with Notepad under Windows. Save a document as "ANSI", "Unicode", "Unicode big endian" and "UTF-8". Open each document in a Hex Editor after saving it. You will notice that some have a "formatting mark" to indicate what type of encoding is used.

This behavior might be intentional, or it might not be. Something to keep in mind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.