public static List <ProxyServer.ProxyServer> ReadServerList() { List <ProxyServer.ProxyServer> list = new List <ProxyServer.ProxyServer>(); string content = ""; if (ReadTextFile(DEFAULT_SERVER_LIST_PATH, out content)) { string[] splitContent = content.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in splitContent) { if (!string.IsNullOrWhiteSpace(item)) { var server = JsonConvert.DeserializeObject <ProxyServer.ProxyServer>(item); // 把加密的秘密解密开 server.LoginPassword = TextEncryption.Decrypt(server.LoginPassword, "password_*12398"); list.Add(server); } } } return(list); }
public static bool SaveServerList(List <ProxyServer.ProxyServer> serverList) { var content = ""; foreach (var server in serverList) { // 密码需要做特殊处理,即对密码进行加密 server.LoginPassword = TextEncryption.Encrypt(server.LoginPassword, "password_*12398"); // 转换为json字符串格式 var json = JsonConvert.SerializeObject(server, Formatting.Indented); content += json + "\n|\n"; } // 保存内容 return(SaveTextFile(DEFAULT_SERVER_LIST_PATH, content)); }