我的测试用例如下:
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/