Base64 encode/decode?

Does TinyCLR have built-in base64 encode/decode? If it does where do I find it?

Sorry if it is obvious and I am just missing it.

string Convert.ToBase64String(byte[] data)
byte[] Convert.FromBase64String(string input)

1 Like

That is where they are on .Net but they don’t appear to be in TinyCLR. Unless I am missing something.

Works for me in TinyCLR… Defined in mscorlib, in namespace System

namespace System
    public static class Convert
        public static bool UseRFC4648Encoding { get; set; }

        public static byte[] FromBase64CharArray(char[] inString, int offset, int length);
        public static byte[] FromBase64String(string inString);
        public static string ToBase64String(byte[] inArray);
        public static string ToBase64String(byte[] inArray, int offset, int length);
        public static byte ToByte(string value);
        public static char ToChar(ushort value);
        public static double ToDouble(string s);
        public static short ToInt16(string value);
        public static int ToInt32(string value);
        public static int ToInt32(string hexNumber, int fromBase);
        public static long ToInt64(string value);
        public static sbyte ToSByte(string value);
        public static ushort ToUInt16(string value);
        public static uint ToUInt32(string value);
        public static ulong ToUInt64(string value);

Would it be listed in the Object Browser?

@mcalsyn to the rescue, thanks!

1 Like

So I found it but it in Object Browser and selecting “Show Hidden Type and Members”. You can see in the screenshot it is slightly greyed out.

Why would it be hidden and how do I unhide it so I can use it?
When I type System.Con. . . Intellisense jumps me right to BitConverter and won’t let me type .Convert.

Okay, I think I figured it out. If I turn OFF Intellisense Suggestion/Completion mode I can type it in and it works. I think it has to do with the
at the top of the class.

Thanks, @mcalsyn for the help!

1 Like

I found that Intellisense is pretty insistent on that one. It really wants to sell me a BitConverter. Alternatively to turning off Intellisense, when the suggestion you don’t want comes up, just use some combination of Ctrl-Z and ESC and type what you do want. The ESC tells IS to shut up for the current completion.

Just in case someone in the future is trying to decode Base64 generated with SitCore with Node.JS. I had to use Convert.UseRFC4648Encoding = true for Node.JS to decode it correctly.

Convert.UseRFC4648Encoding = true;            
var strBase64 = Convert.ToBase64String(_bytes);

It’s not a problem, it just took me a few hours to figure out what was going on. Hopefully, this will help someone in the future.

1 Like

Good find. A quick search also show that this is a potential issue when using Azure SAS authentication.
Non standard Base64 encoding in the .Net Micro Framework | Paolo Patierno (

@greg good stuff here for the docs!

1 Like