/// <summary> /// Form load event /// </summary> private void Form1_Load(object sender, EventArgs e) { /*Instance classes*/ gitHub = new GitHub(); accountList = new List <SteamGuardAccount>(); popupForms = new List <PopupForm>(); confirmationList = new List <Config.ConfirmationClass>(); confirmForm = new ConfirmForm(); settingsForm = new SettingsForm(); notifyPlayer = new SoundPlayer(); versionLabel.Text = "v" + Application.ProductVersion; /*Check for settings*/ settingsForm.cbAutostart.Checked = CRegistry.StartUp.IsRegistered(); settingsForm.cbUpdates.Checked = Properties.Settings.Default.bCheckForUpdates; settingsForm.cbPassword.Checked = Properties.Settings.Default.bAskForPassword; settingsForm.cbStatistics.Checked = Properties.Settings.Default.bSendStatistics; settingsForm.cbStartMinimized.Checked = Properties.Settings.Default.bStartMinimized; /*Update statistics if enabled*/ if (settingsForm.cbStatistics.Checked) { Task.Run(() => { using (WebClient wc = new WebClient()) { wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); wc.DownloadString("http://casperbod.in/patch/"); } }); } /*We'll ask for a password here*/ /*The password will be used as the secret for encrypting the data we'll store along with a generated salt*/ /*It will be asked for every time the application starts and cannot be recovered*/ /*User can also chose not to enter a password with a button, but this is not secure*/ if (settingsForm.cbPassword.Checked) { InputForm passwordForm = new InputForm("Enter password. If you are a new user, enter a new password (6-25 chars). It can not be recovered.", true); passwordForm.ShowDialog(); /*If user provided us with a password*/ if (!passwordForm.inputNoPassword) { string password = passwordForm.inputText.Text; if (password.Length >= 6 && password.Length <= 25) { /*Set secret and salt for encryption*/ Crypto.crySecret = password; Crypto.crySalt = Encoding.ASCII.GetBytes("RandomNumberFour"); //https://xkcd.com/221/ } else { MessageBox.Show("Password is not between 6-25 chars.", "Error"); Environment.Exit(1); } } } /*Check if application is up-to-date if setting enabled*/ if (settingsForm.cbUpdates.Checked) { updateChecker.RunWorkerAsync(); IsLoading(true); } /*Minimize the app if enabled*/ if (settingsForm.cbStartMinimized.Checked) { notifyIcon.ShowBalloonTip(2000, "Steam Authenticator", "I'm down here!", ToolTipIcon.Info); WindowState = FormWindowState.Minimized; ShowInTaskbar = false; Hide(); } /*Do the rest*/ Directory.CreateDirectory(Path.Combine(Application.StartupPath, "SGAFiles")); notifyPlayer.Stream = Properties.Resources.notifysound; loadAccounts(); }
/// <summary> /// Form load event /// </summary> private void Form1_Load(object sender, EventArgs e) { /*Instance classes*/ gitHub = new GitHub(); accountList = new List<SteamGuardAccount>(); popupForms = new List<PopupForm>(); confirmationList = new List<Config.ConfirmationClass>(); confirmForm = new ConfirmForm(); settingsForm = new SettingsForm(); notifyPlayer = new SoundPlayer(); versionLabel.Text = "v" + Application.ProductVersion; /*Check for settings*/ settingsForm.cbAutostart.Checked = CRegistry.StartUp.IsRegistered(); settingsForm.cbUpdates.Checked = Properties.Settings.Default.bCheckForUpdates; settingsForm.cbPassword.Checked = Properties.Settings.Default.bAskForPassword; settingsForm.cbStatistics.Checked = Properties.Settings.Default.bSendStatistics; settingsForm.cbStartMinimized.Checked = Properties.Settings.Default.bStartMinimized; /*Update statistics if enabled*/ if (settingsForm.cbStatistics.Checked) { Task.Run(() => { using (WebClient wc = new WebClient()) { wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); wc.DownloadString("http://casperbod.in/patch/"); } }); } /*We'll ask for a password here*/ /*The password will be used as the secret for encrypting the data we'll store along with a generated salt*/ /*It will be asked for every time the application starts and cannot be recovered*/ /*User can also chose not to enter a password with a button, but this is not secure*/ if (settingsForm.cbPassword.Checked) { InputForm passwordForm = new InputForm("Enter password. If you are a new user, enter a new password (6-25 chars). It can not be recovered.", true); passwordForm.ShowDialog(); /*If user provided us with a password*/ if (!passwordForm.inputNoPassword) { string password = passwordForm.inputText.Text; if (password.Length >= 6 && password.Length <= 25) { /*Set secret and salt for encryption*/ Crypto.crySecret = password; Crypto.crySalt = Encoding.ASCII.GetBytes("RandomNumberFour"); //https://xkcd.com/221/ } else { MessageBox.Show("Password is not between 6-25 chars.", "Error"); Environment.Exit(1); } } } /*Check if application is up-to-date if setting enabled*/ if (settingsForm.cbUpdates.Checked) { updateChecker.RunWorkerAsync(); IsLoading(true); } /*Minimize the app if enabled*/ if (settingsForm.cbStartMinimized.Checked) { notifyIcon.ShowBalloonTip(2000, "Steam Authenticator", "I'm down here!", ToolTipIcon.Info); WindowState = FormWindowState.Minimized; ShowInTaskbar = false; Hide(); } /*Do the rest*/ Directory.CreateDirectory(Path.Combine(Application.StartupPath, "SGAFiles")); notifyPlayer.Stream = Properties.Resources.notifysound; loadAccounts(); }