Does MD5 include the file name?

Does MD5 include the file name?

Secure Home | Search | About
 General Computer 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
Does kernel 2.6 include an NSA backdoor? March 4, 2008, 7:19 pm
'Hijack This' log file May 7, 2004, 12:12 pm
Obscure file - siae3123.exe May 22, 2004, 1:27 pm
snort file logging name December 18, 2004, 5:31 am
the favourities file of Firefox December 21, 2004, 4:39 pm
tcpdump file recovery August 30, 2005, 9:11 am
Tracing a copied file... October 16, 2005, 6:22 am
Limewire file question January 9, 2006, 2:05 pm
PDF File -- Security lock April 12, 2006, 12:43 pm
multiple signatures in an xml file April 24, 2006, 1:34 pm

The site map in XML format XML site map

Contact Us | Privacy Policy