C# to PHP base64 encode/decode

By | March 30, 2018
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 larger strings 100+ chars it fails.
I think this is due to c# adding ‘+’s in the encoding but not sure.
any clues

Answers:

Leave a Reply

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