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); } }
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); } }
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); }
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; } } }