Hi
Yesterday I had a task where I had to encode some string in the Base64 format and then later decode the same back to string. When I first started looking at the System.Convert class, I found the convert to base64 function does not take any string parameter.
You can still convert a string into base64 format in one line of code. The code to convert a string to base64 format is
string str64;
string str64back;
string str="Vikram";
str64 = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(str));
str64back = Text.Encoding.Unicode.GetString(Convert.FromBase64String(str64));
Here I am taking 3 string variable. The variable string is the variable to bhe converted. I first convert the variable to a base64Encoded string(str64) and then convert the base64 string back to simple string that we started with.
Hope this helps
Thanks
Vikram