Windows 中带有 mcrypt 的 PHP 7.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49323908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:45:14  来源:igfitidea点击:

PHP 7.2 with mcrypt in Windows

phpwindowsmcryptphp-7.2

提问by Danilo Davanso

There are some huge legacy systems whose dependencies on PHPs' mcryptare extremely important and vital (including the data storage in database). I need to find a way to maintain this library while upgrading to PHP 7.2 (which already worked fine).

有一些庞大的遗留系统对 PHP 的依赖mcrypt非常重要和至关重要(包括数据库中的数据存储)。我需要找到一种方法来维护这个库,同时升级到 PHP 7.2(已经运行良好)。

My local test environment is Windows. The live environment is run on CentOS.

我的本地测试环境是Windows。live 环境运行在 CentOS 上。

Some of the answers I have seen is decrypting and change mcrypt to openssl (I think that's not possible at the moment since there's a lot of data to decrypt).

我看到的一些答案是解密并将 mcrypt 更改为 openssl(我认为目前这是不可能的,因为有很多数据要解密)。

Another way lights to download a lower PHP version with mcrypt-support, copy the extension and add it to php.ini (I do not even know the folder).

另一种方法是使用mcrypt-support下载较低的PHP版本,复制扩展并将其添加到php.ini(我什至不知道该文件夹)。

Downgrading PHP to 5.6 it's not suitable due to security issues.

由于安全问题,将 PHP 降级到 5.6 是不合适的。

Any light in what could be done in this scenario?

在这种情况下可以做什么?

回答by Blackbam

Basically I think you have mentioned all possibilities and you do not have a choice. Do not downgrade to PHP 5.6 this approach has no future.

基本上我认为你已经提到了所有的可能性,你别无选择。不要降级到 PHP 5.6 这种方法没有前途

MCrypt was removed from PHP for one of the main reasons why you want to upgrade PHP: Security. The MCrypt library is not maintained anymore. Therefore installing the MCrypt extension is also a bad idea. But it can be a temporary solution (follow e.g. those instructions https://serverpilot.io/community/articles/how-to-install-the-php-mcrypt-extension.html).

MCrypt 已从 PHP 中删除,这是您要升级 PHP 的主要原因之一:安全性。MCrypt 库不再维护。因此安装 MCrypt 扩展也是一个坏主意。但它可以是一个临时解决方案(例如遵循这些说明https://serverpilot.io/community/articles/how-to-install-the-php-mcrypt-extension.html)。

The only good solution is migrating from mcrypt to somethingelse. There are questions regarding this topic on Stackoverflow already (e.g. Upgrading my encryption library from Mcrypt to OpenSSL). Alternativly you could use some encryption library. Migrating a large amount of code/data might be a pain but this is the most future-oriented approach in this case.

只有好的解决方案是迁移从mcrypt的东西别人。Stackoverflow 上已经有关于此主题的问题(例如,将我的加密库从 Mcrypt 升级到 OpenSSL)。或者,您可以使用一些加密库。迁移大量代码/数据可能会很痛苦,但在这种情况下,这是最面向未来的方法。

回答by zaph

Note that no code or information about the mcryptoptions/code.

请注意,没有关于mcrypt选项/代码的代码或信息。

Probably the only problems non-standard null padding used by mcrypt. To decrypt with another implementation that does not support null padding (it is non-standard) just decrypt with no padding and then remove the null padding.

可能是mcrypt. 要使用不支持空填充(它是非标准的)的另一个实现解密,只需在没有填充的情况下解密,然后删除空填充。

If you also must encrypt the same as mcryptjust add null padding and encrypt with no-padding.

如果您还必须加密与mcrypt仅添加空填充并使用无填充加密相同。

Really consider migrating the current encryption or adding some flag that the encryption is (or not) mcryptcompatible.

真正考虑迁移当前的加密或添加一些标志,表明加密mcrypt兼容(或不兼容)。

回答by Xavier Maurer

Despite all the warnings and suggestions if you still need to make it work, try this:

尽管有所有警告和建议,如果您仍然需要使其正常工作,请尝试以下操作:

  1. Locate your PHP directory. Usually it is located on C:\Program Files\PHP\v7.2
  2. Then go to this url: http://pecl.php.net/package/mcrypt/1.0.3/windows
  3. Download the package that better meets your requirements. For example if you are using FastCGI and have a 64 bit Windows installation pick 7.2 Non Thread Safe (NTS) x64
  4. Open the zip and copy php_mcrypt.dll file to the C:\Program Files\PHP\v7.2\ext directory.
  5. Edit the php.ini file and add this to the Dynamic extensions section: extension=php_mcrypt.dll
  6. Save php.ini and restart your web server.
  1. 找到您的 PHP 目录。通常它位于 C:\Program Files\PHP\v7.2
  2. 然后去这个网址:http: //pecl.php.net/package/mcrypt/1.0.3/windows
  3. 下载更符合您要求的软件包。例如,如果您使用 FastCGI 并且有 64 位 Windows 安装选择 7.2 Non Thread Safe (NTS) x64
  4. 打开 zip 并将 php_mcrypt.dll 文件复制到 C:\Program Files\PHP\v7.2\ext 目录。
  5. 编辑 php.ini 文件并将其添加到动态扩展部分: extension=php_mcrypt.dll
  6. 保存 php.ini 并重新启动您的 Web 服务器。

Hope it helps.

希望能帮助到你。