Base64 encode/decoding?

I wanted to use base64 for some simple obfuscation of save game data; das anyone ever written a base64 encoding/decoding script in Unity, or does it already exist as a part of mono/.NET and I just don't know it?

Already exists in .NET

Need these two (change using to import for js):

using System;
using System.Text;

Then you encode with (replace byte[] and string with var to make it js compatible):

byte[] bytesToEncode = Encoding.UTF8.GetBytes (inputText);
string encodedText = Convert.ToBase64String (bytesToEncode);

And decode with (change byte[] and string to var again for js):

byte[] decodedBytes = Convert.FromBase64String (encodedText);
string decodedText = Encoding.UTF8.GetString (decodedBytes);

If you are looking for online tool then this is great

Yes, it is possible to encode and decode base64 strings in Unity using C#. The .NET framework, which Unity uses, includes methods for converting data to and from base64 strings. You can use the Convert.ToBase64String method to encode data into a base64 string and the Convert.FromBase64String method to decode a base64 string back into data.

Here is an example of how you can encode and decode a string in C#:

// Encode a string into a base64 string
string originalString = "Hello World";
string encodedString = Convert.ToBase64String(Encoding.UTF8.GetBytes(originalString));

// Decode a base64 string back into a string
byte[] decodedBytes = Convert.FromBase64String(encodedString);
string decodedString = Encoding.UTF8.GetString(decodedBytes);