Does MD5 include the file name?

Does MD5 include the file name?

Secure Home | Search | About
 Computer Software Security    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content add this group's latest topics to your Google content
Subject Author Date
Does MD5 include the file name? Zak 09-12-2006
Posted by Zak on September 12, 2006, 5:54 pm
If you were  Registered and logged in, you could reply and use other advanced thread options
I am running XP.

I have a utility which calculates the MD5 hash for individual files.

I find that it calculates the same MD5 value even if I change the file's
name.



(1) Is the name of the file not used in calculating the MD5 value?

(2) Is this just a quirk of my utility?

Posted by Todd H. on September 12, 2006, 6:10 pm
If you were  Registered and logged in, you could reply and use other advanced thread options
> I am running XP.
>
> I have a utility which calculates the MD5 hash for individual files.
>
> I find that it calculates the same MD5 value even if I change the file's
> name.
>
> (1) Is the name of the file not used in calculating the MD5 value?

That is correct. The hash is computed from the data of hte file. The
filename is stored in the FAT, or the NTFS equivalent thereof, not as
part of the file data.

> (2) Is this just a quirk of my utility?

Nope.

--
Todd H.
http://www.toddh.net/

Posted by Zak on September 13, 2006, 4:57 pm
If you were  Registered and logged in, you could reply and use other advanced thread options
>> I am running XP.
>>
>> I have a utility which calculates the MD5 hash for individual
>> files.
>>
>> I find that it calculates the same MD5 value even if I change the
>> file's name.
>>
>> (1) Is the name of the file not used in calculating the MD5 value?


>
> That is correct. The hash is computed from the data of hte file.
> The filename is stored in the FAT, or the NTFS equivalent thereof,
> not as part of the file data.


>> (2) Is this just a quirk of my utility?
>
> Nope.


Thanks fo the info. Are there other widely used hashes such as the SHA
hashes that do include the name of the file in their calculation?

Posted by Todd H. on September 13, 2006, 5:44 pm
If you were  Registered and logged in, you could reply and use other advanced thread options

> Thanks fo the info. Are there other widely used hashes such as the SHA
> hashes that do include the name of the file in their calculation?

I doubt it.

Think about it, when someone downloads a file, they like to rename it
sometimes, and what path theyput it in varies, so the absolute file
name would be different, dependent on platform, some file systems can
handle mixed case file names, others can't, etc etc.

What situation do you have where you're so concerned about the
filename being included in the check?

There may be others ways leveraging OS calls to do what you want.

--
Todd H.
http://www.toddh.net/

Posted by Doug McIntyre on September 13, 2006, 6:51 pm
If you were  Registered and logged in, you could reply and use other advanced thread options
>Thanks fo the info. Are there other widely used hashes such as the SHA
>hashes that do include the name of the file in their calculation?

A hash is just a hash of data. You need a higher level protocol to
protect the filename.

Say, a requirement of zip'ing the file up into a zip archive, and then
running a hash over that zip file. You can verify your hash on the
ZIP'd file, and be reasonably sure that the filename of the unzip file
will be correct and the same.

There's so many different systems out there that will most likely
mangle the filename in new and strange ways that no typical hash
function would handle a filename change, there'd be too many failures.


Similar ThreadsPosted
Re: portably encrypting a file system's partition, directory and/or file November 25, 2005, 6:10 pm
Is my file secure? February 9, 2006, 4:33 pm
Protected .nfo file March 23, 2007, 6:01 pm
Hosts file download June 25, 2005, 9:53 pm
password protect zip file September 6, 2005, 10:44 am
Index.btr file in Windows XP Help please January 20, 2006, 12:56 pm
secure file formats April 8, 2006, 4:23 pm
blocked file download September 15, 2006, 10:16 am
Erasing File Data May 9, 2007, 4:58 am
File collaboration with encryption July 26, 2007, 11:04 am

The site map in XML format XML site map

Contact Us | Privacy Policy