php mcrypt equivalent for sagepay on a windows server

ⅰ亾dé卋堺 提交于 2019-12-08 07:35:23

问题


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.


回答1:


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




回答2:


An alternative to the native extension is phpseclib

http://phpseclib.sourceforge.net/



来源:https://stackoverflow.com/questions/13360079/php-mcrypt-equivalent-for-sagepay-on-a-windows-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!