Beef icon indicating copy to clipboard operation
Beef copied to clipboard

Implementation of Base64 Encoding/Decoding

Open violinbg opened this issue 2 years ago • 0 comments

I've been trying to implement Base64 Encoding/Decoding since I couldn't find any existing solution for Beef. It allows you to decode/encode between base64 and String/List.

Hoping this could be useful.

I'm not sure if these algorithms are ideal. I did a brute-force approach:

  • On encoding, I grab a group of 3 bytes(chars) and generate the 4 corresponding 6-bits pairs.
  • On decoding, I grab a group of 4 pairs and decode into 3 bytes.

Same usage:

using System.Text;
..
String testMe = "Hello World 123";
var baseEncoded = scope String();
Base64.Encode(testMe, baseEncoded);
Console.WriteLine(baseEncoded);

var baseDecoded = scope String();
Base64.Decode(baseEncoded, baseDecoded);
Console.WriteLine(baseDecoded);

violinbg avatar Sep 04 '22 23:09 violinbg