How to convert a string to contain only numbers and letters

string s = "Foo bar";
string s1 = Convert.ToBase64String(Encoding.Unicode.GetBytes(s));

‘ And back…
string s2 = Encoding.Unicode.GetString(Convert.FromBase64String(s1));

Advertisements