gpt4 book ai didi

php - 使用 PHP 的 DES ECB 加密

转载 作者:搜寻专家 更新时间:2023-10-31 21:02:04 25 4
gpt4 key购买 nike

https://www.tools4noobs.com/online_tools/encrypt/ 给出“a67a318c98a0307502ba81caade2f3a9”作为 key “1234567890abcdef”和有效负载“encrypt this”的 DES ECB 结果。

PHP代码

echo bin2hex(mcrypt_encrypt(
MCRYPT_DES,
hex2bin("1234567890abcdef"),
"encrypt this",
MCRYPT_MODE_ECB)) . "\n";

打印出“1a29ee87f2ad67644ff28450c676a664”。

代码有什么问题?

最佳答案

noobs4tools 网站删除了 hex2bin 函数并将 key 长度截断为 8 个字符(如 Yoshi 在评论中所述)。

对于 12345678 的 key 大小,网站和 PHP 代码的输出是一致的。

DES key 大小在手册中规定为 56 位。请阅读以下有关 DES 特定 key 大小的一些有用背景。

How should I create my DES key? Why is an 7-character string not enough?

noobs4tools 网站使用的 key :

"12345678"

您的代码使用的 key :

 hex2bin("1234567890abcdef"); // 4Vx����

这种差异会给您带来不同的输出。

因此该网站不会将 key 转换为任何其他数字或数据形式。它希望您在页面脚本中提供格式正确的值。

关于php - 使用 PHP 的 DES ECB 加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40015660/

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