码迷,mamicode.com
首页 > 数据库 > 详细

MySQL数据库字段加密

时间:2021-02-15 12:33:14      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:into   sql数据库   exist   arc   binary   解密   arch   str   auto   

一、导入表结构
USE `qskj_03`;
/*Table structure for table `test` */
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
    `id` int(10) NOT NULL AUTO_INCREMENT COMMENT ‘主键‘,
    `username` varchar(200) NOT NULL COMMENT ‘用户名‘,
    `mobile` varchar(100) NOT NULL COMMENT ‘电话号码‘,
    `enmobile` varbinary(100) NOT NULL COMMENT ‘加密后的电话号码‘,
    KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
二、插入一条数据
INSERT INTO test(username,mobile,enmobile)VALUES
(‘曹操‘,‘17779740665‘,AES_ENCRYPT(‘17779740665‘,‘key‘));
三、对加密数据进行解密
SELECT t1.*,AES_DECRYPT(t1.`enmobile`,‘key‘) AS ‘解密后的电话号码‘ 
FROM test t1;

 

MySQL数据库字段加密

标签:into   sql数据库   exist   arc   binary   解密   arch   str   auto   

原文地址:https://www.cnblogs.com/lcl-cn/p/14397996.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!