Пример #1
0
 public void DecryptBase(Account account)
 {
     if (account.Username != null)
     {
         account.Username = DataProtection.Decrypt(account.Username, false);
     }
     if (account.Password != null)
     {
         account.Password = DataProtection.Decrypt(account.Password, true);
     }
 }
Пример #2
0
 public void EncryptBase(Account account)
 {
     if (account.Username != null)
     {
         account.Username = DataProtection.Encrypt(Encoding.UTF8.GetBytes(account.Username), false);
     }
     if (account.Password != null)
     {
         account.Password = DataProtection.Encrypt(Encoding.UTF8.GetBytes(account.Password), true);
     }
 }
Пример #3
0
 public void SaveAccounts(AccountList <ClashAccount> accountList, string file)
 {
     foreach (var account in accountList)
     {
         EncryptBase(account);
         if (account.LoginToken != null)
         {
             account.LoginToken = DataProtection.Encrypt(Encoding.UTF8.GetBytes(account.LoginToken), true);
         }
     }
     SaveSerialized(accountList, file);
 }
Пример #4
0
        public void LoadAccounts(ref AccountList <ClashAccount> accountList, string file)
        {
            accountList = Deserialize <AccountList <ClashAccount> >(file);

            foreach (var account in accountList)
            {
                DecryptBase(account);
                if (account.LoginToken != null)
                {
                    account.LoginToken = DataProtection.Decrypt(account.LoginToken, true);
                    if (account.LoginToken == null)
                    {
                        account.ToonSlot   = 0;
                        account.Authorized = false;
                    }
                }
                else
                {
                    account.ToonSlot   = 0;
                    account.Authorized = false;
                }
            }
        }