Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL MD5 SELECT

Tags:

mysql

md5

This following query returned null.

SELECT `email`, `password`, `salt` FROM `users` WHERE `password` = md5(`salt`+md5('123123'+`salt`)+'123123') AND `email` = '[email protected]'

The following query returned 'd2b4312db21705dafd96df14f8525fef', but why?

SELECT md5( 'Vwm' + md5( '123123' + 'Vwm' ) + '123123' )  

This code returned '422ad0c19a38ea88f4db5e1fecaaa920'.

$salt = 'Vwm';
$password = '123123';

echo md5($salt . md5($password . $salt) . $password);

Do user authorization. How do I create a query to the database so that the first took SALT and SALT have this I did some MD5 function?

like image 504
Isis Avatar asked Jan 30 '11 18:01

Isis


People also ask

How do I find the MD5 password in MySQL?

MD5() function MySQL MD5() Calculates an MD5 128-bit checksum for a string. The value is returned as a binary string of 32 hex digits, or NULL if the argument was NULL. The return value can, for example, be used as a hash key. A string whose MD5 value is to be calculated.

What is MD5 in MySQL?

The MySQL MD5 function is used to return an MD5 128-bit checksum representation of a string. The MD5 message-digest algorithm is a widely used hash function producing a 128-bit hash value. The value returned by the MD5 function is a binary string of 32 hexadecimal digits, or NULL if the argument was NULL.

How decrypt MD5 in MySQL?

You cannot decrypt an md5 hashed string, since it is a one way algorithm. But they can be converted using reverse lookup using mysql. You can refer various online decrypts to find a best solution.

What is MD5 column?

MD5 is a one-way cryptographic hash function with a 128-bit hash value. MD5 returns a 32 character string of hexadecimal digits 0-9 & a-f and returns NULL if the input is a null value.


2 Answers

SELECT md5(CONCAT('Vwm', md5(CONCAT('123123', 'Vwm' )), '123123' )) ;

You need to concat() the strings then execute md5() on them.

This way it returns correctly the same value as your PHP script:

+--------------------------------------------------------------+
| md5(CONCAT('Vwm', md5(CONCAT('123123', 'Vwm' )), '123123' )) |
+--------------------------------------------------------------+
| 422ad0c19a38ea88f4db5e1fecaaa920                             |
+--------------------------------------------------------------+
like image 147
Ass3mbler Avatar answered Oct 21 '22 05:10

Ass3mbler


String concatenation in MySQL requires using CONCAT()`. This;

md5( '123123' + 'Vwm' )

is actually adding a number to a string:

mysql> select '12123' + 'Vwm';
+-----------------+
| '12123' + 'Vwm' |
+-----------------+
|           12123 |
+-----------------+

So your query is not the same as the PHP side, as you're not hashing the same string.

like image 11
Marc B Avatar answered Oct 21 '22 06:10

Marc B