W
W
WhiteNinja2020-11-10 18:29:28
MySQL
WhiteNinja, 2020-11-10 18:29:28

What hashing algorithm to use?

Good evening!

There are about 100,000+ records in the database (constantly replenished).
There is a ProductName field (product name) and a ProductNameHash field (a hash of the product name, ProductName).
The ProductNameHash field is used in a query like

SELECT Id FROM Products WHERE P[email protected]Hash


ProductName length = 50-2500 characters.

The question of safety is not worth it. ProductNameHash can be public, it is not a password or any other secure information.
It is important to exclude the possibility of collisions (get the same ProductNameHash for different ProductNames). And also to make the hash calculation fast enough.

Please tell me which hashing algorithm is best to use in this case for the ProductNameHash field - MD5, SHA1, SHA-256 or something else?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2020-11-10
@Rsa97

It is important to exclude the possibility of collisions
Then pure hash is not good for you. A hash typically maps a set of inputs to a smaller set of hashes, and by definition allows for collisions.

X
xmoonlight, 2020-11-10
@xmoonlight

We need to solve the problem of searching, not creating a hash.
Add tags to the product and search for them.
As a variant of a feature from the name (table of feature identifiers): "contains only one A", "contains only one B", .. etc.
And first, make a selection by feature - filter, and in the received records - already search by full name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question