Ejemplo n.º 1
0
 private void SetPassword(string password)
 {
     try
     {
         _password = Encrypting.EncryptString(password);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.ToString());
     }
 }
Ejemplo n.º 2
0
 public bool CheckPassword(string password)
 {
     try
     {
         return(_password == Encrypting.EncryptString(password));
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.ToString());
         return(false);
     }
 }
Ejemplo n.º 3
0
        private void btnSFSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool passwdChanged       = ApplicationState.GetValue <bool>("passwdChanged");
                bool sharedSecretChanged = ApplicationState.GetValue <bool>("sharedSecretChanged");

                string sql = String.Format("UPDATE tbl_configs SET sfUserID = '{0}', sfAppID = '{1}' WHERE user_pk = 1", txtSFUserID.Text, txtSFAppID.Text);
                if (passwdChanged && !sharedSecretChanged)
                {
                    SecureString securedString   = txtSFPasswd.SecurePassword;
                    string       encryptedString = Encrypting.EncryptString(securedString);
                    sql = String.Format("UPDATE tbl_configs SET sfUserID = '{0}', sfAppID = '{1}', sfPasswd = '{2}' WHERE user_pk = 1", txtSFUserID.Text, txtSFAppID.Text, encryptedString);
                }
                if (sharedSecretChanged && !passwdChanged)
                {
                    SecureString securedString   = txtSFSharedSecret.SecurePassword;
                    string       encryptedString = Encrypting.EncryptString(securedString);
                    sql = String.Format("UPDATE tbl_configs SET sfUserID = '{0}', sfAppID = '{1}', sfSS = '{2}' WHERE user_pk = 1", txtSFUserID.Text, txtSFAppID.Text, encryptedString);
                }
                if (sharedSecretChanged && passwdChanged)
                {
                    SecureString securedPsswd   = txtSFPasswd.SecurePassword;
                    string       encryptedPsswd = Encrypting.EncryptString(securedPsswd);
                    SecureString securedSS      = txtSFSharedSecret.SecurePassword;
                    string       encryptedSS    = Encrypting.EncryptString(securedSS);

                    sql = String.Format("UPDATE tbl_configs SET sfUserID = '{0}', sfAppID = '{1}', sfPasswd = '{2}', sfSS = '{3}' WHERE user_pk = 1", txtSFUserID.Text, txtSFAppID.Text, encryptedPsswd, encryptedSS);
                }

                OpenDB();
                RunSQLCMD(sql);

                System.Windows.MessageBox.Show("Information saved.", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            catch { }
            finally
            {
                ApplicationState.SetValue("passwdChanged", false);
                ApplicationState.SetValue("sharedSecretChanged", false);
                m_dbConnection.Close();
            }
        }
Ejemplo n.º 4
0
 public UserCredentials(string login, string password)
 {
     Login = login;
     _encryptedPassword = Encrypting.EncryptString(password, PrivateKey);
 }