- Home /
Question by
PrimeDerektive · Dec 30, 2010 at 09:14 PM ·
binaryencryptionobfuscationencode
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?
Comment
Best Answer
Answer by Mike 3 · Dec 30, 2010 at 10:36 PM
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);
Answer by patrick625 · Mar 26, 2015 at 02:41 PM
If you are looking for online tool then this is great
Your answer
![](https://koobas.hobune.stream/wayback/20220613093326im_/https://answers.unity.com/themes/thub/images/avi.jpg)