mysql aes_encrypted数据比较

发布于 2025-01-30 09:14:11 字数 921 浏览 2 评论 0原文

I want to compare data encrypted with mysql aes_encrypt() against the encrypted data sent from my app

MySQL version: 10.2.43-MariaDB
Test data: 'abc'
password: '123'
encrypted data sent from my app: 0x911ff5b9a15aae9b52e7e9fde75315b1 

The tests table contains one single record and the column varbinary50 contains data encrypted with mysql's aes_encrypt():

CREATE TABLE `tests` (
  `test_id` int(11) NOT NULL,
  `varbinary50` varbinary(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tests`
--

INSERT INTO `tests` (`test_id`, `varbinary50`) VALUES
(6, 0x911ff5b9a15aae9b52e7e9fde75315b1);

Since varbinary50 contains exactly the value '0x911ff5b9a15aae9b52e7e9fde75315b1', I希望以下查询返回1;取而代之的是0。

select varbinary50='0x911ff5b9a15aae9b52e7e9fde75315b1' from tests

有人可以告诉我我做错了什么吗? tia

I want to compare data encrypted with mysql aes_encrypt() against the encrypted data sent from my app

MySQL version: 10.2.43-MariaDB
Test data: 'abc'
password: '123'
encrypted data sent from my app: 0x911ff5b9a15aae9b52e7e9fde75315b1 

The tests table contains one single record and the column varbinary50 contains data encrypted with mysql's aes_encrypt():

CREATE TABLE `tests` (
  `test_id` int(11) NOT NULL,
  `varbinary50` varbinary(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tests`
--

INSERT INTO `tests` (`test_id`, `varbinary50`) VALUES
(6, 0x911ff5b9a15aae9b52e7e9fde75315b1);

Since varbinary50 contains exactly the value '0x911ff5b9a15aae9b52e7e9fde75315b1', I expect following query to return 1; instead it's 0.

select varbinary50='0x911ff5b9a15aae9b52e7e9fde75315b1' from tests

Could someone tell me what I did wrong? TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青芜 2025-02-06 09:14:11

解决方案:将十六进制应用于Varbinary50并从数据中删除“ 0x”前缀

  select lower(hex(varbinary50))='911ff5b9a15aae9b52e7e9fde75315b1' from tests

Solution: apply hex to varbinary50 and remove "0x" prefix from the data

  select lower(hex(varbinary50))='911ff5b9a15aae9b52e7e9fde75315b1' from tests
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文