php - 哪些迭代规则适用于使用 CRYPT_EXT_DES 的 crypt()?

标签 php des crypt

我的测试用例如下:

echo crypt('string', '_....salt');//error
echo crypt('string', '_A...salt');//fast
echo crypt('string', '_AAAAsalt');//slow

说明如 http://www.php.net/manual/en/function.crypt.php 所述:

CRYPT_EXT_DES - Extended DES-based hash. The "salt" is a 9-character string consisting of an underscore followed by 4 bytes of iteration count and 4 bytes of salt. These are encoded as printable characters, 6 bits per character, least significant character first. The values 0 to 63 are encoded as "./0-9A-Za-z". Using invalid characters in the salt will cause crypt() to fail.

点是可打印字符,为什么会返回错误?哪种“顺序”适用于所使用的字符,导致“AAAA”比“A...”迭代次数更多?

最佳答案

它在引用的段落中说了所有内容: - 最不重要的字符优先 - 值 0 到 63 被编码为“./0-9A-Za-z”

因此在您的示例中,“_....salt”将意味着 0 轮,这显然是行不通的。 考虑到最不重要的字符排在第一位,“_A...salt”小于“_AAAAsalt”。

“_...Asalt”也不仅仅是“_A...salt”

关于php - 哪些迭代规则适用于使用 CRYPT_EXT_DES 的 crypt()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15534982/

相关文章:

javascript - PHP 和 JS mcrypt 解密不起作用

php - 在 Go 中生成 crypt() sha512 哈希

PHP PayPal 自适应支付 - 链式支付

php - PHP 中的 Defined() 发生 fatal error

c# - C# 中的 Des 和 3Des 以及 ecb(来自 C)

c# - 将DES加密数据从Java解密到.Net

css - 这个数据css是什么?

Python 输入密码并与影子密码数据库进行比较

php - MySQL:从 A 列获取对应于 B 列 MIN 的值

php - 开发人员的模型工具 : balsamiq sketchflow