insert into test(username,pwd) values('Jim',ENCODE('123456','Jim'));
select username from test where username='Jim' and pwd=ENCODE('123456','Jim')
insert into test(username,pwd) values('Ryan',SHA('123456'))
select username from test where username='Ryan' and pwd=SHA('123456')
insert into test(username,pwd) values('Jack',MD5('123456'))
select username from test where username='Jack' and pwd=MD5('123456')
Why I can't get a right result by using SHA
and MD5
? Passwords are both 123456, but with different encryption methods I cannot get a right result.
The first can output "Jim" correctly. But the second and the third one cannot output "Ryan" or "Jack", the result set is null
. Why? I want know how to validate a user by encrypted password.