K
K
Ken Jee2015-08-22 18:08:09
PHP
Ken Jee, 2015-08-22 18:08:09

Which algorithm (PHP function) is better to get the hash of a string for subsequent database comparison?

You have to work with long lines. Probably up to 1000 characters. Comparing such volumes is not very reasonable. Tell me, what algorithm is best to use to get the hash of these strings, in order to compare them later through the database (PostgreSQL, although this is not very important in this matter, I think) it is the hashes, because they are clearly shorter in length than the strings from which they are derived. Why is it necessary? To avoid adding rows to the table that already exist.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arman, 2015-08-22
@Machez

crc32() used to be the fastest, now I don't know

P
Pavel Volintsev, 2015-08-24
@copist

sha1 - there are fewer collisions, it is calculated not much longer than md5, length is 40 bytes
Actively used in the BitTorrent and Git protocol

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question