这是MySQL的架构:
CREATE TABLE prevent(
remoteAddr TINYBLOB NOT NULL,
logTime TINYBLOB NOT NULL
)ENGINE=InnoDB;
INSERT prevent VALUES (
AES_ENCRYPT('just a lame test','Wt@F4z5u#r'),
AES_ENCRYPT(NOW(),'b$Do^rK32C')
);
现在简单查询:
SELECT AES_DECRYPT(remoteAddr,'Wt@F4z5u#r') remoteAddr,
AES_DECRYPT(logTime,'b$Do^rK32C') logTime FROM prevent;
但请看结果:http://sqlfiddle.com/#!9/3c507a/3
我的问题是,为什么那些AES_DECRYPT值与我插入的字符串不一样?
答案 0 :(得分:-1)
试试这个:
SELECT CAST(AES_DECRYPT(remoteAddr,'Wt@F4z5u#r')AS CHAR(50)) remoteAddr,
CAST(AES_DECRYPT(logTime,'b$Do^rK32C')AS CHAR(50)) logTime FROM prevent;