gpt4 book ai didi

php - sqlfiddle.com 中的 MYSQL unhex() 不等于 PHP hex2bin(),两者给出不同的结果

转载 作者:行者123 更新时间:2023-11-29 21:12:30 25 4
gpt4 key购买 nike

我正在尝试使用 PHP 而不是 MYSQL 在数据库中添加键值

select unhex(md5('google.com')) from x;

输出

HVkg9LRLJ6gCvXfE8FNvWg==

但是使用 PHP

echo hex2bin((md5("google.com")));

输出

Y ��K'��w��SoZ

我不确定这里出了什么问题,有什么帮助吗?

编辑1约阿希姆·伊萨克森

enter image description here

最佳答案

我不确定您如何获得该值,但是在 MySQL 提示符下进行选择会给出与 PHP 中相同的值;

mysql> select unhex(md5('google.com'));
+--------------------------+
| unhex(md5('google.com')) |
+--------------------------+
| Y �K'��w��SoZ |
+--------------------------+
1 row in set (0.00 sec)

您显示的是同一事物的base64编码值

mysql> select to_base64(unhex(md5('google.com')));
+-------------------------------------+
| to_base64(unhex(md5('google.com'))) |
+-------------------------------------+
| HVkg9LRLJ6gCvXfE8FNvWg== |
+-------------------------------------+
1 row in set (0.00 sec)

你的值是如何进行base64编码的我不确定,但是它似乎与你显示的MySQL查询无关。这可能是由您在 PHP 中获取值的方式引起的。

关于php - sqlfiddle.com 中的 MYSQL unhex() 不等于 PHP hex2bin(),两者给出不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36245741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com