When A MD5 hash from a file dose the hash generates for the File name ? .. or how unique is the MD5 hash from file to file ?
Asked
Active
Viewed 442 times
2 Answers
2
MD5 is long and good enough to prevent random collisions between two files.
But if you have an attacker that can control the files, he can easily create two files that have the same hash. This is because MD5 has collision vulnerabilities. Consider using another hash, such as SHA1. Git uses the SHA1-Hash of files to identify them.

CodesInChaos
- 106,488
- 23
- 218
- 262
-
I have problem .. if we generate the hash a value of two different images with the same file name does the hash is same ? – Sudantha Jan 24 '11 at 08:52
-
If you hash the content of two different files the hashes will be(with extremely high probability) be different. – CodesInChaos Jan 24 '11 at 08:57
-
@Sudantha MD5 doesn't distinguish between file data and file name because it doesn't know anything about the file system. It's up to you to feed necessary data to MD5. – sharptooth Jan 24 '11 at 09:09
1
Whether it will be generated based on file name, contents or both depends on how you implement it. MD5 hashes are quite unique - you can use them for identifying data in many scenarios (specifically when security is not an issue).

Community
- 1
- 1

sharptooth
- 167,383
- 100
- 513
- 979