Two-way Encryption/Decryption between PHP and C# (sharp)

We have been using some simple approaches to securely transfer messages between PHP and C# . We published our method here on github:

https://github.com/ttodua/useful-php-scripts/blob/master/two-way-encrypt-decrypt-PHP-C_sharp

Note, you can use the code not only between PHP-C# communication, but also with each other (PHP-PHP, C#-C#);

Examples:

You can simple output some string from PHP:

echo EncryptDecrypt::EncryptString ( "Hello message to C#", "mySecretKey123" );

and then read it in C# :

Console.WriteLine( EncryptDecrypt::DecryptString ( encryptedStringFromPhp, "mySecretKey123" ) );

Of course, you can do conversely, encrypt message from C# and send to PHP .

p.s. If you also need other kind of encrypt solution solely for PHP, check this code.

( Thanks to articles 1 and 2 )

Leave a Comment

Your email address will not be published. Required fields are marked *

Puvox - Blog
Scroll to Top