Fastest ASP.NET hash function for hashing filenames
I'm trying t开发者_JS百科o optimize my ASP.NET thumbnailing script, so it doesn't resize all the images all the time, and one part of the problem is choosing the hash function for the thumbnail naming/checking procedure.
Is crc32 up to the task? I'm asking cause the input data is small (only relative path, size and date).
You have many choices in hashing that you can use.
What Lasse V. Karlsen commented, that if your hasing the filenames string.GetHashCode() would be good enough if most cases. If your actualy hashing the content of the files your choices range from CRC32,MD5,SH1,SH256-infinte.
If your hashing the files i would guess MD5/SHA1 is going to be good enough. If i where you i would build a test case ( Perhaps with a virutal machine) that runs the lowest hardware your app should support and try MD5 / SHA1. See if that speed is good enough for you and check for Hashing collision ( So have as many pictures as posible in your test case).
Found a good article here with many hashing functions
精彩评论