mysql select returns empty on sha1 hashed password -


i testing hash using sha1 , have inserted row :

insert tbl_user (username, password, email) values ('maysam', sha1('21lf892'), 'gerdakan.sa@gmail.com'); 

and when want select row using :

select * tbl_user password = sha1('21lf892'); 

and result :

 empty set (0.00 sec) 

but if try select using username :

select * tbl_user username  = 'maysam';  +----+----------+--------------------------------+-----------------------+ | id | username | password                       | email                 | +----+----------+--------------------------------+-----------------------+ |  2 | maysam   | dd989b1d1d67c6e706852024ccb6a1 | gerdakan.sa@gmail.com | +----+----------+--------------------------------+-----------------------+ 

what problem? why can't select ?( have tested hashing , selecting using md5 , sha2....

a sha1 hash 160bits, i.e. 40 characters when formatted in way.

your table appears have length of password column set smaller this, data truncated on insert , no longer equal sha1('21f892').

as aside, unsalted sha1 hashes weak way store passwords. prefer bcrypt or scrypt.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -