I am creating a website where users can upload content. As always, I strive for world domination, so I would like not to store the same file twice. For example, if a user tries to download the same file twice (by renaming or just forgetting what she did in the past).
My current approach is for the database to track every downloaded file, storing the following information about each file:
And then a unique index on these three columns. Using two hashes to minimize the risk of false positives.
So my question really is: what is the likelihood of two different ("real world") files of the same size having the same MD5 and SHA1 hashes
Or: Is there a smarter method of similar (un) complexity?
(I understand that the probability may depend on the size of the file).
Thank!
The probability of two real-world files of the same size having the same SHA1 hash is zero for all practical purposes. Some flaws in SHA1 were discovered, but creating a file from the SHA1 hash and size (1) is incredibly expensive in terms of processing power and (2) creates either garbage or the source file.
MD5 - . SHA-1, SHA-2.
, (, SHA1) . , , , .
, MD5 SHA1 . , (SHA1, ) . , , - , . , - , , , "".
edit: MD5 + SHA1. , . , (SHA1, MD5) , 2 ^ -288, , . .
Brogers Rabin. , sha1 md5, , . , , , - , , . , .
#, :
http://www.developpez.net/forums/d863959/dotnet/general-dotnet/contribuez/algorithm-rabin-fingerprint/
Source: https://habr.com/ru/post/1792525/More articles:Is using weak links in Observers a good idea? - observer-patternAndroid: EditText next to ImageView - EditText as wide as possible - androidhow to force show login window using Windows Intergrated autentication - securityHow to get the name of the OS in which the code works using C #? - c #strange behavior cout << Boost :: posix_time - c ++How to add custom VariableResolver to pure JSP - javaCan all programs be converted to assembly? - assemblyContacts such as ListView - androidHow to add custom VariableResolver in JSP Context in Jsp 2.0 to support custom EL? - javaAssigning an empty binary value to a varbinary (MAX) column creates a column with a length of 8000 bytes - sqlAll Articles