string name = "cem"
byte[] barr = "cem".ToCharArray().Select(p=>Convert.ToByte(p)).ToArray();
string converted = Convert.ToBase64String(barr); // converted will be Y2Vt
c e m
99 101 109
Y 2 V t
24 54 21 45
I couldn’t get the math behind of this conversion.
base64 string encoding table: http://tipsforcdevelopers.blogspot.com/2009/05/difference-between-converttobase64strin.html
The table on Wikipedia’s page explains it quite clear.
Each 3 bytes contains 3 x 8 = 24 bits.
These 24 bits are encoded into 4 ASCII characters in Base64 encoding. Which means each ASCII char carries 6 bits of data.
2^6 is 64 so it is possible to use the table to map each 6 bits to an ASCII char.
