Encrypt Key and Decrypt Key with Convert.ToBase64String and Convert.FromBase64String
using System; using System.Data; using System.Configuration; using System.Web; public class SecurityHelper { public static string EncryptKey(string key) { char[] arr = key.ToCharArray(); for (int ii = 0; ii < arr.Length; ii++) { arr[ii] ^= (char)14; } byte[] b = new byte[arr.Length]; for (int ii = 0; ii < arr.Length; ii++) { b[ii] = (byte)arr[ii]; } return Convert.ToBase64String(b); } public static string DecryptKey(string key) { byte[] b = Convert.FromBase64String(key); char[] arr = new char[b.Length]; for (int ii = 0; ii < b.Length; ii++) { arr[ii] = (char)(b[ii] ^ 14); } return new string(arr); } }