Answer the question
In order to leave comments, you need to log in
Convert string to base64?
What could be the problem?
There is a task to convert a string to base64,
For example, the string " {"response":"2,4,5"} " should become " eyJyZXNwb25zZSI6IjIsNCw1In0. "
I'm trying to convert the following code:
public static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
Answer the question
In order to leave comments, you need to log in
You have correctly converted.
"=" special suffix code
From wikipedia:
"If only one or two bytes are encoded, the result is only the first two or three characters of the string, and the output string is padded with two or one "=" characters. This prevents extra bits from being added to the recovered data. "
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question