What is the best hash method for an array of byte?
The arrays are serialized class objects containing jpeg image passed between applications over TCP/IP.
The array size is about 200k.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any of the built-in hashing functions should do; depending on how much you care about collisions these are your options (from most collisions to least):
They are as simple to use as:
Bonus Marks: If you don’t care about security (which I don’t think you do given that you are getting the hashes for images) you might want to look into Murmur hash, which is designed for content hashing and not secure hashing (and is thus much faster). It isn’t, however, in the framework so you will have to find an implementation (and you should probably go for Murmur3).
Edit: If you are looking for a HASHCODE for a byte[] array it’s entirely up to you, it usually consists of bit shifting (by primes) and XORing. E.g.
EDIT: If you want to validate that the value hasn’t changed you should use CRC32.