Q:

Converting to base64 adds a return character

I'm trying to convert a Dictionary to a string end then Base64 it in order to save it to another string.
Here's my code
public class StringBase64Helper
{
    public static string Base64Encode(string plainText)
    {
        var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
        return Convert.ToBase64String(plainTextBytes, Base64FormattingOptions.InsertLineBreaks);
    }

    public static string Base64Decode(string base64EncodedData)
    {
        var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
        return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
    }
}

and I use servicestack to serialize it
var dictionary = new Dictionary<string,object>();

dictionary.Add("VM","XX.XXXXXXXXX.Client.WPF.ViewModels.PortfolioManager");

var rr =ServiceStack.Text.JsonSerializer.SerializeToString(dictionary);

var str = StringBase64Helper.Base64Encode(rr);

The output I've is
eyJWTSI6IlhYLlhYWFhYWFhYWC5DbGllbnQuV1BGLlZpZXdNb2RlbHMuUG9ydGZvbGlvTWFuYWdl
ciJ9

Note that c1J9 is a new row, since it put's 
 character's when storing the string inside my main file.
The json from the Serializer is " 
     {"VM":"XX.XXXXXXXXX.Client.WPF.ViewModels.PortfolioManager"}"
When I decode the string I got
{"VM":"XX.XXXXXXXXX.Client.WPF.ViewModels.PortfolioManage

and after the new line I got
r"}

What am I doing wrong?

A:

You specified Base64FormattingOptions.InsertLineBreaks.
If you don't want line breaks; don't ask for them!
public static string Base64Encode(string plainText)
{
    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
    return Convert.ToBase64String(plainTextBytes);
}

