mysql加密与解密decode与encode乱码解决方法(转)
mysql decode 加密与解密
更新加密
UPDATE card SET test=ENCODE(NAME,'kljlsfjasdf') WHERE id=1;
解密的方法
更新加密
UPDATE card SET test=ENCODE(NAME,'kljlsfjasdf') WHERE id=1;
解密的方法
SELECT DECODE(test,'kljlsfjasdf') FROM card WHERE id=1
乱码则执行
SELECT CAST(BINARY(DECODE(test,'kljlsfjasdf')) AS CHAR CHARACTER SET utf8) AS VALUE FROM card WHERE id=1
乱码则执行
SELECT CAST(BINARY(DECODE(test,'kljlsfjasdf')) AS CHAR CHARACTER SET utf8) AS VALUE FROM card WHERE id=1
DROP TABLE IF EXISTS `card`;
CREATE TABLE `card` (
`id` int(14) NOT NULL AUTO_INCREMENT,
`card_id` varchar(18) CHARACTER SET utf8 DEFAULT NULL,
`name` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
`test` varchar(255) COLLATE latin1_general_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
COLLATE=latin1_general_ci CHECKSUM=1 DELAY_KEY_WRITE=1
ROW_FORMAT=DYNAMIC;
/*Data for the table `card` */
insert into `card`(`id`,`card_id`,`name`,`test`) values (1,'52040219770325X064','李四','Œ(S6Š×');