MySQL字段加密和解密 1.加密:aes_encrypt('admin','key') 解密:aes_decrypt(password,'key') 2.双向加密 通过密钥去加密,解密的时候的只有知道这个密钥的人来解密 加密:encode() 解密:decode() eg:encode('123456' 'adfdgfdhggfh'); decode(password,'adfdgfdhggfh'); 3.PASSWORD('123456') password加密是不可逆转的 4.MD5('123456') //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 rs=pstmt.executeQuery(); if(rs.next()){ resultUser=new User(); resultUser.setUserName(rs.getString(1)); resultUser.setPassword(rs.getString(2)); System.out.println(resultUser.getPassword()+"^^^^^"); } return resultUser; } } //sql语句 insert into t_user (userName,password) values('admin',AES_ENCRYPT('123456','key')); select userName,AES_DECRYPT(password,'key')password from t_user;
URL: http://www.cnblogs.com/ryy1210/p/6228738.html
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索解密
, 加密
, key
, 密钥
, username
, 1210
, mysql getstring
, AES_DECRYPT
, password
, aes解密
mysql双向加密解密
mysql字段加密解密、数据库字段加密解密、oracle字段加密解密、mysql加密解密、mysql md5加密解密,以便于您获取更多的相关知识。
时间: 2024-11-05 12:24:53