Example #1
0
        private void btnSetMasterKey_Click(object sender, RoutedEventArgs e)
        {
            string newKeyText = txtNewMasterKey.Text.Trim();

            if ((string.IsNullOrEmpty(newKeyText)) || (newKeyText.Length < 3))
            {
                MessageBox.Show("ERROR: Master key not long enough. Key must be longer than 3 characters");
            }
            else
            {
                MSPWDStorage.SetMasterKeyFile(MSPWDCrypto.CreateMasterKey(txtNewMasterKey.Text.Trim()));
                txtNewMasterKey.Text = string.Empty;

                // Add the "delete master key" page back
                if (!pvtPages.Items.Contains(tabSpecial))
                {
                    pvtPages.Items.Add(tabSpecial);
                }
                if (!pvtPages.Items.Contains(tabAlpha))
                {
                    pvtPages.Items.Add(tabAlpha);
                }
                if (!pvtPages.Items.Contains(tabClean))
                {
                    pvtPages.Items.Add(tabClean);
                }

                pvtPages.SelectedItem = tabSpecial;
            }
        }
        /// <summary>
        /// Creates a password with special characters, using the specified string as a seed
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string CreatePassword_Special(string input)
        {
            // Convert the given string to a byte array so we can work with it
            byte[] inputBytes = Encoding.Unicode.GetBytes(input);

            // Retreive the user's master key
            byte[] MasterKey = MSPWDStorage.GetMasterKey();

            return(GenPasswordWithThisHash(characterArray_Special, SHA256(CombineByteArrays(inputBytes, MasterKey))));
        }
Example #3
0
        private void btnEraseKey_Click(object sender, RoutedEventArgs e)
        {
            MSPWDStorage.DeleteMasterKey();
            pvtPages.SelectedItem = tabKey;
            pvtPages.Items.Remove(tabSpecial);
            pvtPages.Items.Remove(tabAlpha);
            pvtPages.Items.Remove(tabClean);

            txtCleanDescription.Visibility = System.Windows.Visibility.Visible;
            btnEraseKeyPrompt.Visibility   = System.Windows.Visibility.Visible;

            txtCleanSure.Visibility  = System.Windows.Visibility.Collapsed;
            btnEraseKey.Visibility   = System.Windows.Visibility.Collapsed;
            btnDoNotErase.Visibility = System.Windows.Visibility.Collapsed;
        }
Example #4
0
        public MainPage()
        {
            InitializeComponent();

            // If this is the first run of the app, show the master key page
            if (!MSPWDStorage.MasterKeyFileExists())
            {
                pvtPages.SelectedItem = tabKey;

                // We don't need to delete a key that doesn't exist, so hide the tab
                pvtPages.Items.Remove(tabClean);
                pvtPages.Items.Remove(tabAlpha);
                pvtPages.Items.Remove(tabSpecial);
            }
            else
            {
                pvtPages.SelectedItem = tabSpecial;
            }

            // Event handlers for clearing data if the app is closed or backgrounded
            PhoneApplicationService.Current.Closing     += Current_Closing;
            PhoneApplicationService.Current.Deactivated += Current_Deactivated;
        }