i am using Encoding and decoding :
For Encoding:
private string EncodeServerName(string ServerName)
    {
      byte[] NameEncodein = new byte[ServerName.Length];
      NameEncodein = System.Text.Encoding.UTF8.GetBytes(ServerName);
      string EcodedName = Convert.ToBase64String(NameEncodein);
      return EcodedName;
    }
and Decoding:
     public string DecoAndGetServerName(string Servername)
     {
         System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
         System.Text.Decoder strDecoder = encoder.GetDecoder();
         byte[] to_DecodeByte = Convert.FromBase64String(Servername);
         int charCount = strDecoder.GetCharCount(to_DecodeByte, 0, to_DecodeByte.Length);
         char[] decoded_char = new char[charCount];
         strDecoder.GetChars(to_DecodeByte, 0, to_DecodeByte.Length, decoded_char,0);
         string Name = new string(decoded_char);
         return Name;
     }
I am sending ServerName:DEV-SQL1\SQL2008
It is encoded:REVWLVNRTDFcU1FMMjAwOA==
Again i want to decode but getting Exception:in line:
byte[] to_DecodeByte = Convert.FromBase64String(Servername);
Exception IS:
`The input is not a valid Base-64 string as it contains a non-base 64 character,
more than two padding characters, or a non-white space character among the padding characters.`
How to solve this issue.
Please Help Me
 
     
    