ASP.NET Web Application
3 posts
• Page 1 of 1
ASP.NET Web Application
Hello and Thank you for this wonderful tool that is Phalanger. My project is in Webforms and I have some php code I want to use with C#. I installed Phalanger with the setup, created a phalanger library class named PayPlugLibrary which content is :
I referenced the ddl in my project, imported the namespaces in my code
When I try to create an object
I need those functions to process information for a third party website. I have had a hard time trying to rewrite these functions in C#, I couldn't. I am not familiar with PHP.
May be I am doing this wrong ? I need to send information to those functions and get returned values. Please Help !
- Code: Select all
<?php
namespace PayPlugLibrary {
class PayPlug {
public function __construct() {
}
public function PayPlug()
{
}
function build_data_params($amount, $currency, $ipn_url)
{
$params = array('amount'=>$amount, 'currency'=>$currency, 'ipn_url'=>$ipn_url);
$data_params = http_build_query($params);
return $data_params;
}
function generate_signature($value, $private_key)
{
$privatekey = openssl_pkey_get_private($private_key);
openssl_sign($url_params, $signature, $privatekey, OPENSSL_ALGO_SHA1);
$signature = urlencode(base64_encode($signature));
return $signature;
}
}
}
?>
I referenced the ddl in my project, imported the namespaces in my code
- Code: Select all
using PHP.Core;
using PHP.Library;
using PayPlugLibrary;
When I try to create an object
- Code: Select all
PayPlug PP = new PayPlug();
I need those functions to process information for a third party website. I have had a hard time trying to rewrite these functions in C#, I couldn't. I am not familiar with PHP.
May be I am doing this wrong ? I need to send information to those functions and get returned values. Please Help !
- cam-D357
- Posts: 1
- Joined: April 27th, 2014, 7:58 pm
Re: ASP.NET Web Application
Hi,
Thanks for using Phalanger!
There is small trick to create C# wrappers for PHP classes.
Classes that have to be wrapped has to contain following attribute above the class header:
Or you can mark all the classes in your project by adding following somewhere
Thanks for using Phalanger!
There is small trick to create C# wrappers for PHP classes.
Classes that have to be wrapped has to contain following attribute above the class header:
- Code: Select all
[\Export]
Or you can mark all the classes in your project by adding following somewhere
- Code: Select all
[assembly: \Export]class XYZ{}
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: ASP.NET Web Application
Hi,
I stuck somewhere.
I tried heavy googling from my side but no hope.
Than ultimately I decided to request you for help.
Actually I am .NET developer. Here I required to call a PHP code from .net.
So, what I did--- I created a PHP lib project using PHALANGER.
I put following code in a PHP class in that Lib project—
--------------------------(Code start)----------------------------------------
<?php
[assembly: \System\Reflection\AssemblyTitle("PHPLib")]
[assembly: \Export] // Special attribute // In the result, all PHP class functions will be wrapped in C#-like methods.
class AssemblyInfo
{
public function DecryptNow() {
$initialVector = "x2qecedrucruswaj";
$secretKey = "pharmacist news, Pharmacy news, news for pharmacists, news for community pharmacists,CPD articles and resources from Chemist + Druggist";
$encryptedData = "1kRO7v8D+oqUT7qVLkDIdNmja0SF/Ng5jJSTAtfR9uTdG/rwuTD+vb9vWC23DSL3z/ZywzQRK0juYwF634e9mlYPgik3x2iC74zUgi3LUmI0tvl993gkl2/FkZtVBh16r4FDXZKCfLbFOB+OS7PzKU0U1loqQgNQ4elXWEllL7saNZEuEgkJzSZwExItn79Xdv02CpMREMVoquPApjUQ+JcK+by1a7r5hyRgPr+6fvKnegrEcLvTb/bmF/ZYDjFDcrUhLmJPAh5xv1ElP0P8pbOKbfO+YU/Nt8UzCLIaNocijdH8VYQTaR3UEeJSiGQ8JGeapmKK3vU67rkJ3S88Z5+fwDZOSBz52vea1Kyfajc5zWrBpISV70FG+2KhgMrxP8h+mHMPnAy+X4HSpgcIv+l4e4nXnLfOaB9gWKpDDwQ4PXHsdnKdIPt4EY7MTxzdweh06NDsBdsF0E8HyMf5+jmIPJI0BhfhNYf79RzPR/cir5U8R2N0K0TUZlDhtUweq6xX05avVzDNXTEBLQ7grVisfMOSqLfZQZ3uDmHrWXoHRN4yDx1kX4Xq997fwPfD0S0fn/7N1EPmolJ5RUbyecg+LDV9opT1D4nj9mVeJYLleKlMlivdZAUFDZMqqg5hx0FZF8BCz/wYxmPKJZnksDnDOwPG/I/B9Q6R+9XtYEIIxnbEg+m3gOqeaK2/UkKP9FAp+L+jv2nOXKlgiEuLYrkghqEUewTD/7hiFqaL9scA5DU+ZwD2I+xUaxr0hP1bB+dNlzCFeZGVfWq4/09bI3X3R3WVrkmtmWijlxZyOI6CRYgt7Vhv9DNXWA/0yfXdA6BTzX3gGXZ0TFrUGNCsQz/4E7halCKr5OxXH/ff0nShXSeUy+fYik3btiunQnDecVxiFLxaAIRuRksBALQf";
$decryptedString = mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
md5($secretKey),
base64_decode($encryptedData),
MCRYPT_MODE_CFB,
$initialVector
);
$myfile = fopen("c:/test.txt", "w") or die("Unable to open file!");
$txt = $decryptedString;
fwrite($myfile, $txt);
fclose($myfile);
}
public function sum()
{
return 5;
}
}
?>
-----------------------------(Code end)------------------------------
Now, here the issue is --- the inbuid function mcrypt_decrypt is not recognisable here. It is saying “Call to unknown function: mcrypt_decrypt”.
Can you please help to figure it out.
It will be a great support for me.
I stuck somewhere.
I tried heavy googling from my side but no hope.
Than ultimately I decided to request you for help.
Actually I am .NET developer. Here I required to call a PHP code from .net.
So, what I did--- I created a PHP lib project using PHALANGER.
I put following code in a PHP class in that Lib project—
--------------------------(Code start)----------------------------------------
<?php
[assembly: \System\Reflection\AssemblyTitle("PHPLib")]
[assembly: \Export] // Special attribute // In the result, all PHP class functions will be wrapped in C#-like methods.
class AssemblyInfo
{
public function DecryptNow() {
$initialVector = "x2qecedrucruswaj";
$secretKey = "pharmacist news, Pharmacy news, news for pharmacists, news for community pharmacists,CPD articles and resources from Chemist + Druggist";
$encryptedData = "1kRO7v8D+oqUT7qVLkDIdNmja0SF/Ng5jJSTAtfR9uTdG/rwuTD+vb9vWC23DSL3z/ZywzQRK0juYwF634e9mlYPgik3x2iC74zUgi3LUmI0tvl993gkl2/FkZtVBh16r4FDXZKCfLbFOB+OS7PzKU0U1loqQgNQ4elXWEllL7saNZEuEgkJzSZwExItn79Xdv02CpMREMVoquPApjUQ+JcK+by1a7r5hyRgPr+6fvKnegrEcLvTb/bmF/ZYDjFDcrUhLmJPAh5xv1ElP0P8pbOKbfO+YU/Nt8UzCLIaNocijdH8VYQTaR3UEeJSiGQ8JGeapmKK3vU67rkJ3S88Z5+fwDZOSBz52vea1Kyfajc5zWrBpISV70FG+2KhgMrxP8h+mHMPnAy+X4HSpgcIv+l4e4nXnLfOaB9gWKpDDwQ4PXHsdnKdIPt4EY7MTxzdweh06NDsBdsF0E8HyMf5+jmIPJI0BhfhNYf79RzPR/cir5U8R2N0K0TUZlDhtUweq6xX05avVzDNXTEBLQ7grVisfMOSqLfZQZ3uDmHrWXoHRN4yDx1kX4Xq997fwPfD0S0fn/7N1EPmolJ5RUbyecg+LDV9opT1D4nj9mVeJYLleKlMlivdZAUFDZMqqg5hx0FZF8BCz/wYxmPKJZnksDnDOwPG/I/B9Q6R+9XtYEIIxnbEg+m3gOqeaK2/UkKP9FAp+L+jv2nOXKlgiEuLYrkghqEUewTD/7hiFqaL9scA5DU+ZwD2I+xUaxr0hP1bB+dNlzCFeZGVfWq4/09bI3X3R3WVrkmtmWijlxZyOI6CRYgt7Vhv9DNXWA/0yfXdA6BTzX3gGXZ0TFrUGNCsQz/4E7halCKr5OxXH/ff0nShXSeUy+fYik3btiunQnDecVxiFLxaAIRuRksBALQf";
$decryptedString = mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
md5($secretKey),
base64_decode($encryptedData),
MCRYPT_MODE_CFB,
$initialVector
);
$myfile = fopen("c:/test.txt", "w") or die("Unable to open file!");
$txt = $decryptedString;
fwrite($myfile, $txt);
fclose($myfile);
}
public function sum()
{
return 5;
}
}
?>
-----------------------------(Code end)------------------------------
Now, here the issue is --- the inbuid function mcrypt_decrypt is not recognisable here. It is saying “Call to unknown function: mcrypt_decrypt”.
Can you please help to figure it out.
It will be a great support for me.
- Ankur
- Posts: 1
- Joined: November 18th, 2015, 12:06 pm
3 posts
• Page 1 of 1
Return to PHP/C# interoperability
Who is online
Users browsing this forum: No registered users and 0 guests