예제 #1
0
 public void SaveXmlExprotConfiguration()
 {
     try
     {
         if (!Directory.Exists(LoginInfo.ExprotConfigFolder))
         {
             Directory.CreateDirectory(LoginInfo.ExprotConfigFolder);
         }
         new DirectoryInfo(LoginInfo.ExprotConfigFolder).Attributes = FileAttributes.Hidden;
         if (File.Exists(this.LoginInfoConfigPath))
         {
             File.Delete(this.LoginInfoConfigPath);
         }
         new XDocument(new object[1]
         {
             (object)new XElement((XName)"LoginInfoConfig", new object[4]
             {
                 (object)new XElement((XName)"UserName", (object)this.UserName),
                 (object)new XElement((XName)"UserPassword", (object)LoginEncrypt.Encrypt(this.UserPassword, "E99F9354-BC29-48A2-9839-F3D0DD83CCE5")),
                 (object)new XElement((XName)"IsRememberPassWord", (object)this.IsRememberPassWord),
                 (object)new XElement((XName)"IsAutoLogin", (object)this.IsAutoLogin)
             })
         }).Save(this.LoginInfoConfigPath);
     }
     catch (Exception)
     {
     }
 }
예제 #2
0
        public static byte[] Decrypt(byte[] encrypted, byte[] key)
        {
            TripleDESCryptoServiceProvider cryptoServiceProvider = new TripleDESCryptoServiceProvider();

            cryptoServiceProvider.Key  = LoginEncrypt.MakeMD5(key);
            cryptoServiceProvider.Mode = CipherMode.ECB;
            return(cryptoServiceProvider.CreateDecryptor().TransformFinalBlock(encrypted, 0, encrypted.Length));
        }
예제 #3
0
 private void ConfigInit()
 {
     if (File.Exists(this.LoginInfoConfigPath))
     {
         try
         {
             XmlNode node = XmlAnalysis.GetNode((XmlNode)XmlAnalysis.ReaderXmlFile(this.LoginInfoConfigPath), "LoginInfoConfig");
             this.IsRememberPassWord = Convert.ToBoolean(XmlAnalysis.GetNode(node, "IsRememberPassWord").InnerText);
             this.UserName           = XmlAnalysis.GetNode(node, "UserName").InnerText;
             string innerText = XmlAnalysis.GetNode(node, "UserPassword").InnerText;
             this.IsAutoLogin  = Convert.ToBoolean(XmlAnalysis.GetNode(node, "IsAutoLogin").InnerText);
             this.UserPassword = LoginEncrypt.Decrypt(innerText, "E99F9354-BC29-48A2-9839-F3D0DD83CCE5", Encoding.Default);
         }
         catch (Exception)
         {
             this.Init();
             File.Delete(this.LoginInfoConfigPath);
         }
     }
     else
     {
         this.Init();
     }
 }
예제 #4
0
 public static string Decrypt(string encrypted, string key, Encoding encoding)
 {
     byte[] encrypted1 = Convert.FromBase64String(encrypted);
     byte[] bytes      = Encoding.Default.GetBytes(key);
     return(encoding.GetString(LoginEncrypt.Decrypt(encrypted1, bytes)));
 }
예제 #5
0
 public static string Encrypt(string original, string key)
 {
     return(Convert.ToBase64String(LoginEncrypt.Encrypt(Encoding.Default.GetBytes(original), Encoding.Default.GetBytes(key))));
 }