Base64 to Hex using C# plugin

When viewing Binary values, one of the most common ways to show it is Hexadecimal Code. It’s basically a code for each binary character starting from 0 to 9, and then a to z, consisting of 2 values per code. This is very often used for colour codes on websites. Colour codes are RGB (Red, Green, Blue) and the value is given like this: #000000 (0 Red, 0 Green, 0 Blue) for black, #ffffff for white (255 Red, 255 Green, 255 Blue). And any combination thereof to create the colour pallet.

However, in Linx when we use Binary, we normally talk about a List of bytes (List), which can also be converter to a Base64 string. This List closely resembles the numbered values above, so the value for the colour white would be [255,255,255].

But, in many cases we still need the Hex value. To get this, you can use the C# plugin in Linx and use this bit of code in it to convert a Base64 string to a Hex string:

string Function(string b64)
{
byte bytes = Convert.FromBase64String(b64);
string hex = BitConverter.ToString(bytes);
return hex;
}

So, if you’ve got a word “White” then these would be it’s different values:

String: “White”
List: [87,104,105,116,101]
Baase64: V2hpdGU=
Hex: 57-68-69-74-65