php mcrypt等效于Windows服务器上的sagepay [英] php mcrypt equivalent for sagepay on a windows server

查看:132
本文介绍了php mcrypt等效于Windows服务器上的sagepay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到最近,我们公司才开始使用vbscript,当我们开始变为PHP时。在尝试将SagePay表单套件整合到我们的一个项目中时,我遇到了这个障碍。



我们在Windows 2008服务器上,无法更改。服务器不包含mcrypt库,由于它是共享平台,我们的服务器主机将不会安装它。



有问题的行来自SagePay表单套件,您可以使用SagePay支付费用。希望你们中的一些人会熟悉这些。



有问题的是:

 code> // **使用PHP的MCRYPT模块执行加密
$ strCrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$ strEncryptionPassword,$ strIn,MCRYPT_MODE_CBC,$ strIV);

这是更大的加密函数的一部分,如下所示:

  // ** Wrapper函数根据strEncryptionType设置加密编码** 
函数encryptAndEncode($ strIn){

全局$ strEncryptionType
,$ strEncryptionPassword;

if($ strEncryptionType ==XOR)
{
// **使用Base64编码的XOR加密**
返回base64Encode(simpleXor($ strIn, $ strEncryptionPassword));
}
else
{
// ** AES加密,CBC封锁PKCS5填充然后HEX编码 - DEFAULT **

// **使用初始化向量(IV)从$ strEncryptionPassword
$ strIV = $ strEncryptionPassword;

// **添加PKCS5填充到待被文本的
$ strIn = addPKCS5Padding($ strIn);

// **使用PHP的MCRYPT模块执行加密
$ strCrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$ strEncryptionPassword,$ strIn,MCRYPT_MODE_CBC,$ strIV);

// **执行十六进制编码并返回
返回@。 BIN2HEX($ strCrypt);
}
}

有谁知道我可能能够绕过这个问题,还是我可以在其中实现的等效的库?任何指针,提示或点在正确的方向将是非常感谢。



编辑好的,所以经过研究更多,据了解,我只需要一个128位AES加密功能,而不使用mcrypt。

解决方案

有很多替代方案,缺乏您的提供者的支持/意愿将是粘性点。



如果您是自己的VPS /能够下一条新路线。我建议OpenSSL; http://www.openssl.org/ - 由于您在Windows上可能会查看 http://slproweb.com/products/Win32OpenSSL.html



您是否通过 phpinfo()查看可用的内容?



还有PCrypt ;
http ://www.phpclasses.org/package/1610-PHP-Symetric-encryption-of-data-using-only-PHP-code.html


Our company primarily used vbscript until fairly recently, when we started changing to PHP. Upon trying to integrate a SagePay form kit into one of our projects I came across this obstacle.

We are on a windows 2008 server, and this cannot be changed. The server does not contain the mcrypt library and our server host will not install it due to it being a shared platform.

The problematic line comes from a SagePay form kit that you use to pay for things with SagePay. Hopefully some of you will be familiar with these.

The line in question is:

//** perform encryption with PHP's MCRYPT module
$strCrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $strEncryptionPassword, $strIn, MCRYPT_MODE_CBC, $strIV);

This is part of a larger encrytion function as follows:

//** Wrapper function do encrypt an encode based on strEncryptionType setting **
function encryptAndEncode($strIn) {

    global $strEncryptionType
          ,$strEncryptionPassword;

    if ($strEncryptionType=="XOR") 
    {
        //** XOR encryption with Base64 encoding **
        return base64Encode(simpleXor($strIn,$strEncryptionPassword));
    } 
    else 
    {
        //** AES encryption, CBC blocking with PKCS5 padding then HEX encoding - DEFAULT **

        //** use initialization vector (IV) set from $strEncryptionPassword
        $strIV = $strEncryptionPassword;

        //** add PKCS5 padding to the text to be encypted
        $strIn = addPKCS5Padding($strIn);

        //** perform encryption with PHP's MCRYPT module
        $strCrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $strEncryptionPassword, $strIn, MCRYPT_MODE_CBC, $strIV);

        //** perform hex encoding and return
        return "@" . bin2hex($strCrypt);
    }
}

Does anyone know how I may possibly be able to bypass this problem, or an equivalent library that I may be able to implement in its place? Any pointers, tips or points in the correct direction would be most appreciated.

EDIT Ok so after researching it more, as I understand it, I just need a 128 bit AES Encryption function, without the use of mcrypt.

解决方案

There are plenty of alternatives, the lack of support/willingness from your hosing provider would be the sticky point.

If you were on your own VPS/In a position to go down a new route. I'd recommend OpenSSL; http://www.openssl.org/ - Since you're on windows maybe check out http://slproweb.com/products/Win32OpenSSL.html

Have you checked through phpinfo()to see what is available to you?

There is also PCrypt; http://www.phpclasses.org/package/1610-PHP-Symetric-encryption-of-data-using-only-PHP-code.html

这篇关于php mcrypt等效于Windows服务器上的sagepay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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