Does MD5 include the file name?

Does MD5 include the file name?

am 12.09.2006 23:54:59 von Zak

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?

Re: Does MD5 include the file name?

am 13.09.2006 00:10:39 von comphelp

Zak writes:
> 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/

Re: Does MD5 include the file name?

am 13.09.2006 00:20:50 von unruh

Zak writes:

>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.

Yes.



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

It is not included. MD5 of a file is the hash of the contents of that file.


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

No.

Re: Does MD5 include the file name?

am 13.09.2006 22:57:27 von Zak

> Zak writes:
>> 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?


On 12 Sep 2006, Todd H. wrote:
>
> 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?

Re: Does MD5 include the file name?

am 13.09.2006 23:44:29 von comphelp

Zak writes:

> 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/

Re: Does MD5 include the file name?

am 14.09.2006 00:51:25 von Doug McIntyre

Zak writes:
>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.

Re: Does MD5 include the file name?

am 14.09.2006 06:36:43 von Zak

On 13 Sep 2006, Doug McIntyre wrote:

> Zak writes:
>>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.
>

I have some speech audio files. One or two may have been re-worked
while tinkering with the audio editor.

I would like to hash them to check if one file is identical to another.
But some names have changes so I don't want to us a hash calculation
which might also base itself on the name.

Seems from what folks say that it is very nnlikely.

Re: Does MD5 include the file name?

am 14.09.2006 07:38:06 von Volker Birk

Zak wrote:
> Are there other widely used hashes such as the SHA
> hashes that do include the name of the file in their calculation?

This has nothing to do with hashing algorithms, it's an attribute of the
implementation of your checksum program.

BTW: SHA1 is b0rken, better use RIPEMD-160 instead.

Yours,
VB.
--
Viel schlimmer als die Implementation von PHP ist jedoch das Design.

Rudolf Polzer in de.comp.security.misc

Re: Does MD5 include the file name?

am 14.09.2006 08:07:00 von comphelp

Zak writes:

> I have some speech audio files. One or two may have been re-worked
> while tinkering with the audio editor.
>
> I would like to hash them to check if one file is identical to another.
> But some names have changes so I don't want to us a hash calculation
> which might also base itself on the name.
>
> Seems from what folks say that it is very nnlikely.

Then just use md5sum for the hashing, and call it a day. It ignores
filenames.



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

Re: Does MD5 include the file name?

am 14.09.2006 20:27:05 von jiang

> Then just use md5sum for the hashing, and call it a day. It ignores
> filenames.


Now that we are at it, anyone can reccomend an easy freeware for Windows XP
to compare file hashes?

Re: Does MD5 include the file name?

am 14.09.2006 20:44:52 von comphelp

jiang writes:

> > Then just use md5sum for the hashing, and call it a day. It ignores
> > filenames.
>
>
> Now that we are at it, anyone can reccomend an easy freeware for Windows XP
> to compare file hashes?

cygwin.com framework includes md5sum by default i believe.

md5sum both files, and eyeball the resulting fingerprint.


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