Tag Archives: c++

Run C++ script in PHP

Questions: I have a C++ program that needs to take data from a PHP script, process it, and return the data to my PHP script. How do you pass the values from PHP to C++? How do you run the C++ script? Do you have to compile it first some how? How do you get… Read More »

tripledes encryption not yielding same results in PHP and C#

Questions: When I encrypt with C# I get arTdPqWOg6VppOqUD6mGITjb24+x5vJjfAufNQ4DN7rVEtpDmhFnMeJGg4n5y1BN static void Main(string[] args) { Encoding byteEncoder = Encoding.Default; String key = “ShHhd8a08JhJiho98ayslcjh”; String message = “Let us meet at 9 o’clock at the secret place.”; String encryption = Encrypt(message, key, false); String decryption = Decrypt(encryption , key, false); Console.WriteLine(“Message: {0}”, message); Console.WriteLine(“Encryption: {0}”, encryption); Console.WriteLine(“Decryption:… Read More »

C# to PHP base64 encode/decode

Questions: So I have this c# application that needs to ping my web server thats running linux/php stack. I am having problems with the c# way of base 64 encoding bytes. my c# code is like: byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(“the string”); String enc = Convert.ToBase64String(encbuff); and php side: $data = $_REQUEST[‘in’]; $raw = base64_decode($data); with… Read More »

Decrypt string in C# that was encrypted with PHP openssl_encrypt

Questions: I have a customer encrypting a string in PHP with the following code: $password = ‘Ty63rs4aVqcnh2vUqRJTbNT26caRZJ’; $method = ‘AES-256-CBC’; texteACrypter = ‘Whether you think you can, or you think you can\’t–you\’re right. – Henry Ford’; $encrypted = openssl_encrypt($texteACrypter, $method, $password); which results in this encrypted output: MzVWX4tH4yZWc/w75zUagUMEsP34ywSYISsIIS9fj0W3Q/lR0hBrHmdvMOt106PlKhN/1zXFBPbyKmI6nWC5BN54GuGFSjkxfuansJkfoi0= When I try to decrypt that string… Read More »

What is the equivalent of branch reset operator (“?|”) found in php(pcre) in C#?

Questions: The following regular expression will match “Saturday” or “Sunday” : (?:(Sat)ur|(Sun))day But in one case backreference 1 is filled while backreference 2 is empty and in the other case vice-versa. PHP (pcre) provides a nice operator “?|” that circumvents this problem. The previous regex would become (?|(Sat)ur|(Sun))day. So there will not be empty backreferences.… Read More »

Decrypt PHP encrypted string in C#

Questions: I have a string encrypted in PHP that I would like to decrypt in C#. I used the tutorial below to do the encryption, but am having problems decrypting. Can anyone post an example on how to do this? http://www.sanity-free.org/131/triple_des_between_php_and_csharp.html Answers:

How can I use C++ code to interact with PHP?

Questions: I was reading somewhere that sometimes PHP is simply not fast enough and that compiled code has to sometimes “do the heavy lifting” What is the api in C++ to do this? Answers:

What is the C# equivalent of the PHP Pack() function?

Questions: I have a line of PHP code that does the following: $xml = “<xml><request>…[snipped for brevity]…</request></xml>”; $request = pack(‘N’, (strlen($xml)+4)).$xml; What this appears to do is prepend a binary string of the length of $xml (plus 4) to the value of $xml. How do I do the equivalent of this in C#? Answers:

Convert PHP to C++ code [closed]

Questions: I’m looking for a way to convert PHP code to C++. There are a few reasons I want to do so: Main reason: There are bunch of great PHP tools/software that I’d love to use and incorporate into C++ GUI or non-GUI applications To boost performance To avoid dependency on PHP libraries To avoid… Read More »