Provides simple symmetric AES-256 encryption for passwords.
Пример #1
0
        public void Save()
        {
            SettingsFile sf = new SettingsFile();

            sf.Set("SignInUsername", SignInUsername);
            sf.Set("PlayerName", PlayerName);
            sf.Set("Password", PasswordSecurity.EncryptPassword(Password));
            sf.Set("LastUrl", LastUrl);
            sf.Set("SignInDate", SignInDate.Ticks);
            sf.Save(FileName);
        }
Пример #2
0
 public void LoadAccounts()
 {
     storedAccounts.Clear();
     string[] fileNames = Directory.GetFiles(Paths.DataDirectory, "*.account");
     foreach (string fileName in fileNames)
     {
         try {
             SettingsFile sf = new SettingsFile();
             sf.Load(fileName);
             SignInAccount newAccount = new SignInAccount {
                 SignInUsername = sf.GetString("SignInUsername", ""),
                 PlayerName     = sf.GetString("PlayerName", ""),
                 Password       = sf.GetString("Password", ""),
                 LastUrl        = sf.GetString("LastUrl", "")
             };
             if (newAccount.Password.Length > 0)
             {
                 newAccount.Password = PasswordSecurity.DecryptPassword(newAccount.Password);
             }
             string tickString = sf.GetString("SignInDate", "0");
             long   ticks;
             if (Int64.TryParse(tickString, out ticks) && ticks > DateTime.MinValue.Ticks &&
                 ticks <= DateTime.MaxValue.Ticks)
             {
                 newAccount.SignInDate = new DateTime(ticks);
             }
             else
             {
                 newAccount.SignInDate = DateTime.MinValue;
             }
             AddAccount(newAccount);
         } catch (Exception ex) {
             MainForm.Log("AccountManager.LoadAccounts: " + ex);
         }
     }
     SaveAllAccounts();
 }