mcrypt在Windows / IIS上的PHP 5.6中不起作用 [英] mcrypt doesn't work in PHP 5.6 on windows/IIS

查看:326
本文介绍了mcrypt在Windows / IIS上的PHP 5.6中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在php应用程序中一直在大量使用mcrypt多年,无论是在win / IIS还是在linux上。虽然我在我的linux服务器上运行PHP 5.4.28,但我刚刚在我的Windows 8.1 IIS框中升级到了PHP 5.6.11。而mcrypt不再工作。它不会抛出任何可以看到的错误;它只是不行。这是我的加密功能:

I have been making heavy use of mcrypt in my php app for years, both on win/IIS and on linux. Although I'm running PHP 5.4.28 on my linux server, I just upgraded to PHP 5.6.11 on my windows 8.1 IIS box. And mcrypt no longer works. It doesn't throw any errors that I can see; it just doesn't work. Here is my encryption function:

function Encrypt($text){ 
    global $salt;
    if($text != "")
        return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));  
    else
        return "";
}   

这在我的Linux服务器上工作正常,但在我的本地窗口框中返回空白。从我所看到的,mcrypt内置到php 5.6 for Windows中,所以应该没有扩展名或ini文件。

This works fine on my linux server, but returns blank on my local windows box. From what I have read, mcrypt is built into php 5.6 for windows, so there should be no fiddling with extensions or ini file.

我缺少什么?

推荐答案

PHP 5.6具有比5.4更强的加密要求。在5.6中你会得到这个警告,这是一个错误,因为它实际上导致加密和解密失败:

PHP 5.6 has stronger encryption requirements than 5.4. In 5.6 you'll get this warning, which is really an error because it actually causes encryptions and decryptions to fail:


警告:mcrypt_encrypt ):此算法不支持大小xx的键。只支持尺寸为16,24或32的键。

Warning: mcrypt_encrypt(): Key of size xx not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported.

...其中xx是您的盐值的长度。因此,盐值必须正好是16,24或32个字符。

...where "xx" is the length of your salt value. So the salt value has to be exactly 16, 24, or 32 characters in length.

这篇关于mcrypt在Windows / IIS上的PHP 5.6中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆