I try to decrypt data which is encrypted with PHP from local money transfer service.
There is PHP example as following:
<?php
require_once('phpseclib/Crypt/AES.php');
define('API_PASSKEY', 'abcdefghijklmnop');
if($_SERVER['REMOTE_ADDR'] == '203.146.127.115' && isset($_GET['request']))
{
$aes = new Crypt_AES();
$aes->setKey(API_PASSKEY);
$_GET['request'] = base64_decode(strtr($_GET['request'], '-_,', '+/='));
$_GET['request'] = $aes->decrypt($_GET['request']);
if($_GET['request'] != false)
{
parse_str($_GET['request'],$request);
$request['Ref1'] = base64_decode($request['Ref1']);
echo 'SUCCEED';
}
else
{
echo 'ERROR|INVALID_PASSKEY';
}
}
else
{
echo 'ERROR|ACCESS_DENIED';
}
?>
However, I want to do decrypt with C#.
I also set up simple PHP encrypt text for testing but cannot decrypt with C# either.
<?php
include('phpseclib/Crypt/AES.php');
$aes = new Crypt_AES();
$aes->setKey('abcdefghijklmnop');
$plaintext = 'Hello';
$cryptoText = $aes->encrypt($plaintext) ;
$cryptoText = base64_encode( $cryptoText);
echo $cryptoText . "<br/>";
echo $aes->decrypt(base64_decode($cryptoText));
?>
I looking forward to get your good suggestion.
phpseclib uses CBC by default with PKCS#7 padding enabled and 128-bit keys if that helps.