![]() |
| Home | Apache | PHP | Ubuntu | MySQL | Linux | HTML | Win | CSS | Perl | Javascript | Rants | Retro |
|
||
| Encrypt a password using MySQL This example we will create a MD5 encrypted password # We need to create a table called user_md5, (The value is returned as a binary string of 32 hex digits) CREATE TABLE user_md5 (user_name VARCHAR(16), password VARCHAR(32)); Query OK, 0 rows affected (0.10 sec) # Now we need to insert a user into the table INSERT INTO user_md5 VALUES ('test',MD5('test') ); Query OK, 1 row affected (0.00 sec) # Now lets see if we query the user with the unencrypted password will it work SELECT * FROM user_md5 where user_name = 'test' AND password=MD5('test'); +———–+———————————-+ | user_name | password | +———–+———————————-+ | test | 098f6bcd4621d373cade4e832627b4f6 | +———–+———————————-+ 1 row in set (0.00 sec) |