featured-image-how-to-prove-2-files-same

How To Prove If 2 Files Are Identical (Windows, Mac & Linux)

Check for file verification between 2 files, no matter what operating system you are using.

When verifying if two files are identical, both must be the same, technically speaking, from the first byte to the last.

They can have different filenames, but they are duplicates of each other.

How do we prove that?

It is not practical to, for example, check all the contents of two lengthy Word documents or inspect every pixel for 2 similar file images.

How to know if two files are exactly the same file?

Here are the four (4) different ways to prove if two files are the same.


1. Using a Hashing Algorithm

The fastest and most accurate method is to check if two files are identical, have the same content, and replicate the other.

Legally speaking, in a court of law, the use of both MD5 and SHA-1 hashing algorithms are scientifically accepted and widely used to determine if two digital files are exactly the same.

Both hashes are cryptographic hash functions, using mathematics to generate a 128-bit string value (for MD5) or a 160-bit string value.

You can generate a hash value for any text or paragraph, any digital file, e.g. image, video or document, and even a transaction.

Below is an example of 2 similar images, using MD5 hashes to prove if they are the same file.

MD5 = 1CE434071294B9E7AEC68CA5191E2F87
example-file-for-hashing
MD5 = 1CE434071294B9E7AEC68CA5191E2F87

Both hash values are the same; therefore, both images are duplicate files without any differences or modifications.

Using Windows PowerShell – (for Windows)

Using the Windows PowerShell command-line quickly without installing any additional tools since it is already in-built into the operating system.

Type “Powershell” into the Windows Search bar and open it.

Copy and paste the following code into the command prompt, changing the file path (highlighted in blue).

if((Get-FileHash "path-to-fileA").hash -eq (Get-FileHash "path-to-fileB").hash) {"Both Files Are Identical"} else {"Both Files Are NOT Identical"}

Change the “path-to-FileA” and “path-to-FileB” accordingly to the 2 files you want to test.

windows-powershell-filehash

When 2 files are identical, the output will be “Both Files Are EXACTLY THE SAME”

Using HashMyFiles – (for Windows)

hashmyfiles

HashMyFiles is a small utility tool that requires no installation (drag & drop files) and supports up to Windows 10.

It can calculate both MD5 and SHA-1 hash values.

Using Mac Terminal – (for Mac users)

Open Terminal and enter this simple command below (changing the 2 files to your own).

md5 FileA.jpg FileB.jpg
mac-terminal-md5-hash-two-files

When both file hashes match, they are exactly the same file.

You can also calculate the SHA-1 hash using;

shasum -a 1 FileA FileB

Using Linux Shell – (for Linux users)

Open Terminal and enter this short command, pointing to your file, to generate your MD5 hash value.

md5sum filename.jpg

2. Using the Microsoft Word application

Compare feature

Use this method if you want to compare 2 different Word documents.

Regardless of the operating system, you are using, the Microsoft Office Word application itself has a “Compare” feature we can use.

Note: this method is only used to compare the contents of both files and not to prove if they are the exact replicate of each other (exact bit-by-bit).

1) Open Word application,
2) Click on the “Review” tab,
3) Go to the “Compare” dropdown menu,
4) Choose “Compare Documents” and select the 2 Word Documents you want to verify.

When both files are the same, MS word will return a message box like this (below).

microsoft-word-compare-feature

3. Using the Notepad++ application

Compare plugin

Use this method to compare 2 text files, source files, log files and SQL databases.

Notepad++ is a windows-only application that many programmers use to perform source-code editing.

It is a reliable replacement for the native Notepad application in Windows operating system.

Note: Similar to the MS Word method above, Notepad++ allows for comparing the contents of both files.

1) Open the Notepad++ application
2) Go to [Plugins] – [Plugin Manager] – [Show Plugin Manager]
3) Select the [Compare] plugin and click [Install]

Now, open the 2 files separately in 2 different Notepad++ applications.

From the [Plugins] menu, select [Compare] and again, select [Compare]

You can now see both files side-by-side, and if you notice any yellow highlight portion, these are the content differences between both files.


4. Using Online Tools

If the files or content you want to verify are not sensitive, you can opt to use these online services to check their authenticity.

DiffChecker

DiffChecker

DiffChecker allows for comparing text, images, PDF, Excel and even folders.

It is also available as a desktop app for Windows, Mac and Linux.

CopyLeaks

Like DiffChecker, you can copy the entire text content from 2 different files and paste it on Copyleaks for comparison to see if they are identical.

You can also upload the files or provide the URL address for Copyleaks to check.

OnlineMD5

OnlineMD5 is a simple online service that generates MD5 and SHA-1 hash values.

You can paste your text content or easily upload a file for quick hash computation.

The maximum upload file size is 4GB.

With that, you could even hash an entire ISO image or even a video file.


Summary

To prove if 2 digital files are the exact copy of each other, always use a cryptographic hash like MD5 and SHA-1. It is the most accurate way to prove the authenticity of two digital files.

MD5 & SHA-1 hash algorithms are often used in a court of law to verify digital files.

To compare only the contents of two files, use the rest of the methods stated in this article.

Consider using any of the online hashing services mentioned above when the files & contents are not sensitive to you.

Leave a Comment

Your email address will not be published. Required fields are marked *