mcrypt 可以执行 crypt() 支持的相同算法吗?

发布于 2024-10-05 22:20:53 字数 368 浏览 0 评论 0原文

我有一个在 PHP 5.3 上运行的应用程序,它存储使用 PHP 的 crypt() 函数哈希的密码。但是,默认情况下,我正在使用的运行 PHP 5.2 的服务器之一上所使用的哈希类型 (SHA 512) 不可用。我发现使用 mcrypt 可以获得更大的灵活性,但使用起来也更复杂。

是否可以使用 PHP 的 mcrypt 函数获得与 crypt (使用 SHA512 salt)相同的结果?

因此,如果我使用 SHA512 salt 输入“test”,则使用 crypt() 和使用 mcrypt() 时的加密数据应该相同。

如果不可能,任何人都可以给我建议,告诉我还能做什么吗?不幸的是,升级到 PHP 5.3 不是一个选择(它是一个云服务器,我没有时间为此编写脚本)。

I have an app that runs on PHP 5.3 which stores passwords hashed using PHP's crypt() function. However the hashing type (SHA 512) used is not available by default on one of the servers I'm now using which runs PHP 5.2. I've seen that with mcrypt you get a lot more flexibility but it's also more complicated to use.

Is it possible to use PHP's mcrypt functions to get the same results as with crypt (using a SHA512 salt)?

So if I input "test" with an SHA512 salt the encrypted data should be the same when using crypt() as well as when using mcrypt().

If it's not possible, can anyone give me advice on what else to do? Unfortunately upgrading to PHP 5.3 is not an option (it's a cloud server and I don't have the time to write the scripts for that).

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

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

发布评论

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

评论(2

勿忘心安 2024-10-12 22:20:53

谁能告诉我是否可以使用php5的mcrypt函数来获得与crypt相同的结果

否。Mcrypt 提供了加密解密函数。 crypt,尽管其名称具有欺骗性,但提供了以下功能: 哈希。这些不是同一个任务。 Mcrypt不提供任何哈希函数,您要使用的算法(SHA-512)是哈希算法。

您无法使用 Mcrypt 对密码进行哈希处理。那不是它的工作。它的作用和crypt的作用不同并且不重叠。

Can anyone tell me if it's possible to use php5's mcrypt function to get the same results as with crypt

No. Mcrypt provides functions for encryption and decryption. crypt, despite its deceptive name, provides functions for hashing. These are not the same task. Mcrypt does not provide any hashing functions, and the algorithm you want to use (SHA-512) is a hashing algorithm.

You cannot hash passwords with Mcrypt. That isn't its job. Its role and crypt's are different and do not overlap.

左耳近心 2024-10-12 22:20:53

不幸的是 MCrypt 没有 SHA512 密码 - 您可以在此处查看密码列表:

http://www.php.net/manual/en/mcrypt.ciphers.php

Unfortunately MCrypt doesn't have the SHA512 cipher - you can take a look at the list of ciphers here:

http://www.php.net/manual/en/mcrypt.ciphers.php

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