6
6
655362018-04-28 02:00:33
PHP
65536, 2018-04-28 02:00:33

How to quickly create a hash that fully identifies an array?

I use the floating version

function jmd5($input)
{
    return md5(json_encode($input));
}

Something tells me that there is a more low-level solution. Often used in kilometer cycles and noticeably slows down.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2018-04-28
@xmoonlight

Maybe try xxHash ?

Name 		Speed 		Quality 	Author
xxHash 		5.4 GB/s 	10 		Y.C.
MurmurHash 3a 	2.7 GB/s 	10 		Austin Appleby
SBox 		1.4 GB/s 	9 		Bret Mulvey
Lookup3 	1.2 GB/s 	9 		Bob Jenkins
CityHash64 	1.05 GB/s 	10 		Pike & Alakuijala
FNV 		0.55 GB/s 	5 		Fowler, Noll, Vo
CRC32 		0.43 GB/s 	9 	
MD5-32 		0.33 GB/s 	10 		Ronald L.Rivest
SHA1-32 	0.28 GB/s 	10

S
Stalker_RED, 2018-04-28
@Stalker_RED

Fully identifying - no way , because any hashing can cause collisions .
Of course, there are faster algorithms than md5, but the shorter the hash, the greater the chance of collisions.
(benchmarks 1 , 2 , 3 )
Hint: isn't serialize faster than json_encode?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question