No offense, but there's certainly a more elegant solution. I'm not sure why you're catching a specific exception just to throw a more general one either.
Code:public string Encode(string str) { byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(str); return Convert.ToBase64String(encbuff); } public string Decode(string str) { byte[] decbuff = Convert.FromBase64String(str); return System.Text.Encoding.UTF8.GetString(decbuff); }




Reply With Quote