MySQL encryption and md5 Encryption

Source: Internet
Author: User

MySQL encryption and md5 Encryption

MySQL field encryption and decryption 1. encryption: aes_encrypt ('admin', 'key') Decryption: aes_decrypt (password, 'key') 2. two-way encryption is encrypted by the key. Only the person who knows the key is used for decryption. encryption: encode () Decryption: decode () eg: encode ('000000' 'adfdgfdhggfh'); decode (password, 'adfdgfdhggfh'); 3. PASSWORD ('000000') password encryption is irreversible 4. MD5 ('200') // UserDao public User login (Connection con, User user) throws Exception {User resultUser = null; String SQL = "select userName, AES_DECRYPT (password, 'key ') Password from t_user where userName =? And AES_DECRYPT (PASSWORD, 'key') =? "; PreparedStatement pstmt = con. prepareStatement (SQL); pstmt. setString (1, user. getUserName (); pstmt. setString (2, user. getPassword (); ResultSet rs1_pstmt.exe cuteQuery (); if (rs. next () {resultUser = new User (); resultUser. setUserName (rs. getString (1); resultUser. setPassword (rs. getString (2); System. out. println (resultUser. getPassword () + "^");} return resultUser;} // SQL statement insert into t_user (userName, password) values ('admin ', AES_ENCRYPT ('123', 'key'); select userName, AES_DECRYPT (password, 'key') password from t_user;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.