Beispiel #1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to change your login?", "Change Login", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                string password;
                while (true)
                {
                    password = Microsoft.VisualBasic.Interaction.InputBox("Please enter your password to continue", "Change Login");
                    if (string.IsNullOrWhiteSpace(password))
                    {
                        break;
                    }
                    else
                    {
                        byte[]        pass     = Encoding.ASCII.GetBytes(password);
                        HMACSHA512    hmac1    = new HMACSHA512(pass);
                        StringBuilder sb       = new StringBuilder();
                        byte[]        passHash = hmac1.ComputeHash(pass);
                        foreach (byte b in passHash)
                        {
                            sb.Append((char)b);
                        }
                        if (sb.ToString() == Properties.Settings.Default.Password)
                        {
                            break;
                        }
                        else
                        {
                            MessageBox.Show("Password was incorrect", "Change Login");
                        }
                    }
                }
                if (string.IsNullOrWhiteSpace(password))
                {
                    MessageBox.Show("Login was not reset", "Change Login");
                    return;
                }

                //Decrypt data and prepare for re-encryption
                if (!ContentFile.CheckValidity())
                {
                    ContentFile.Decrypt(password);
                }
                else
                {
                    ContentFile.Archive = ZipFile.Open(ContentFile.ContentPath, ZipArchiveMode.Update);
                }

                //TODO - MOVE TO CONTENT FILE
                Properties.Settings.Default.Password = "";
                Properties.Settings.Default.Username = "";
                Properties.Settings.Default.Save();

                Paging.LoadPage(Pages.Register);
            }
            else
            {
                MessageBox.Show("Login was not reset");
            }
        }
Beispiel #2
0
        private void page_Loaded(object sender, RoutedEventArgs e)
        {
            if (Data.Groups.Count == 0)
            {
                pgProgress.Visibility = lblStatus.Visibility = Visibility.Visible;
                waitThread            = new Thread(() => Thread.Sleep(2000));
                bgWork.DelegateThread(() =>
                {
                    if (!ContentFile.CheckValidity())
                    {
                        ContentFile.Decrypt(Login.Password);
                    }
                    else
                    {
                        ContentFile.Archive = ZipFile.Open(ContentFile.ContentPath, ZipArchiveMode.Update);
                    }

                    ContentFile.LoadData();
                    Dispatcher.Invoke(() => { pgProgress.Visibility = lblStatus.Visibility = Visibility.Collapsed; });
                    SpinWait.SpinUntil(() => !waitThread.IsAlive);
                    if (MainWindow.ImportOnLogin)
                    {
                        Paging.LoadPage(Pages.Import);
                    }
                    else
                    {
                        Paging.LoadPage(Pages.Viewer);
                    }
                });
                waitThread.Start();
            }
            else
            {
                Paging.LoadPage(Pages.Viewer);
            }
        }