Пример #1
0
        public object ConvertBack(object value, Type targetType, object parameter,
                                  System.Globalization.CultureInfo culture)
        {
            string pass = PasswordProtect.EncryptStringAES(value.ToString(), MainWindow.Secret);

            return(pass);
        }
Пример #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (new ValidationClass().CheckIfNotEmpty(LoginBox.Text, LocationBox.Text, PasswordBox.Text))
            {
                var passwordSet = new PasswordSet();
                passwordSet.Location = LocationBox.Text;
                passwordSet.Login    = LoginBox.Text;

                passwordSet.Password = PasswordProtect.EncryptStringAES(PasswordBox.Text, MainWindow.Secret);

                passwordSet.UserUserId  = MainWindow.LoggedUser;
                passwordSet.Status      = "active";
                passwordSet.DateCreated = DateTime.Now;
                passwordSet.DateChanged = DateTime.Now;
                try
                {
                    MainWindow.context.PasswordSets.Add(passwordSet);
                    MainWindow.context.SaveChanges();
                    DialogResult = true;
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.ToString());
                }
            }
            else
            {
                MessageBox.Show("Please populate all fields!");
            }
        }