Dilemma, searching for a hashed field when no other information is known

I have a dilemma. I have a field hashedXthat is a hashed / salted value, and the salt is stored on the same line in the mysql database as normal practice.

hashedX      saltX
------       ------
hashed1      ssai3
hashed2      woddp
hashed3      92ofu

When I receive inputX, I need to know if it matches any of the values ​​in hashedX, for example hashed1 hashed2or hashed3. Therefore, as a rule, I would take my input, hash / salt it and compare it with the values hashedX. Pseudocode:

$hashed_input = hash ($input with $salt );
select * from tablename where $hashed_input is hashedX

The problem is that I don’t know which one saltXI even need to get to $hashed_inputbefore I can do any select.

, , , / hashedX . 100 000 , , . , , .

  • , , , , db?
+3
3

( -), MySQL User Defined Function hash (. CREATE FUNCTION). , :

SELECT hashedX, saltX FROM tablename WHERE UDFhash(input, saltX) = hashedX ;
+3

, PHP. MySQL - MD5 SHA1 :

SELECT ...
FROM tablename 
WHERE SHA1(CONCAT(?, saltX)) = hashedX;

SHA2 MySQL 5.5, - . . http://dev.mysql.com/doc/refman/5.5/en/news-5-5-x.html .

+1

, , , -, db?

. .

, . , .

, , , + . , / , , , + .

, , ( ) , .

- /, , .

+1

Source: https://habr.com/ru/post/1753611/


All Articles