K
K
kuzemchik2012-03-26 11:29:40
PHP
kuzemchik, 2012-03-26 11:29:40

Need hash function for integer array?

Need a fast hash function to get the hash from an array of numbers. You need the same for PHP and JS (check the integrity on the client and server). If there are no ready ones, then links to algorithms for obtaining a hash from an array will also go.
Thank you.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
CrazySquirrel, 2012-03-26
@kuzemchik

Serialize an array (for example json) and take a hash from a string (for example md5).
When choosing hash functions, don't forget that they can create collisions.

A
Andrew, 2012-03-26
@OLS

The chances of an accidental (!) MD5 collision are negligible.

U
uglymeta, 2012-03-26
@uglymeta

A heuristic algorithm comes to mind - add up all the numbers in the array and either use the sum itself to check or md5 from it.

E
egorinsk, 2012-03-27
@egorinsk

XOR or XOR + multiply by 7.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question