so I have the following problem: I'm encoding a file's contents in C# with UTF-8 into base64, then URL-encoding it and sending a GET request to my php, then I url decode it there and then base64 decode it. The outcome is not 1:1 to the file I encoded in C#, no matter what. I've tried all encodings in C#, neither of them work. Am I supposed to do something else here? I'd also like to mention that I'm echoing back the file into an octet stream, perhaps echo can't "echo" UTF-8 characters?
Here's my Base64 Encoding in C#:
public static string Base64Encode(string plainText)
{
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
string base64 = System.Convert.ToBase64String(plainTextBytes);
return WebUtility.UrlEncode(base64);
}
Here's how I decode it in PHP:
base64_decode(urldecode($_GET["parameter"]));
And here's how I'm downloading it:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="<filename>"');
echo(base64_decode(urldecode($_GET["parameter"])));
Thanks.