1Define ("ENCRYPT",'2998a15c0cd853edad7');// Key Key2 3 4 field of the stored database is set to BLOB format (binary)5 //Aes_encrypt Encryption6 Insert into' Ks_user ' (user_name, user_pwd)Values('kstest', Aes_encrypt ('aa123456','2998a15c0cd853edad7'));7 8 //Aes_decrypt Decryption9 SelectIduser_name, Aes_decrypt (User_pwd,'2998a15c0cd853edad7') asUser_pwd from' Ks_user ';Ten +----+-----------+----------+ One |Id| user_name |User_pwd| A +----+-----------+----------+ - | 8 |Kstest|aa123456| - | 7 |Hanks|aa123456| the +----+-----------+----------+ - 2Rowsinch Set(0.16sec) - - Select * from' Ks_user ';//The raw data is stored in a binary + +----+-----------+------------------+ - |Id| user_name |User_pwd| + +----+-----------+------------------+ A | 8 |Kstest|f? Heaven?5? f at | 7 |Hanks|f? Heaven?5? f - +----+-----------+------------------+ - 2Rowsinch Set(0.15Sec
MySQL Encryption and decryption case