Exemple #1
0
        public void Words_100Pass()
        {
            List <string> Passwords = new List <string>();
            int           i         = 0;

            while (i < 100)
            {
                WordsGenerator TestGenerator = new WordsGenerator();
                Passwords.Add(TestGenerator.Next(WordsFormat));
                Console.WriteLine(Passwords[i]);
                i++;
            }

            if (Passwords.GroupBy(n => n).Any(c => c.Count() > 1))
            {
                Assert.Fail("Duplicates found");
            }
        }
Exemple #2
0
        public void Words_1Pass()
        {
            WordsGenerator TestGenerator = new WordsGenerator();

            Console.WriteLine(TestGenerator.Next(WordsFormat));
        }
Exemple #3
0
        // Words
        private void BkgWordsGen_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            // Lock UI
            Action BlockUI = () => grpWordsSettings.Enabled = false;

            grpWordsSettings.Invoke(BlockUI);

            // Save Settings
            string savePattern = "";

            foreach (char component in wordsFormat)
            {
                switch (component)
                {
                case 'A':
                    savePattern = savePattern + ":Adjective";
                    break;

                case 'D':
                    savePattern = savePattern + ":Adverb";
                    break;

                case 'N':
                    savePattern = savePattern + ":Noun";
                    break;

                case 'V':
                    savePattern = savePattern + ":Verb";
                    break;
                }
            }
            Properties.Words.Default.Pattern = savePattern.Substring(1);
            Properties.Words.Default.Save();

            // Generate Passwords based on the settings defined.
            WordsGenerator Generator = new WordsGenerator();
            List <string>  Passwords = new List <string>();
            int            i         = 0;

            while (i < 10)
            {
                Passwords.Add(Generator.Next(wordsFormat));
                i++;
            }
            Generator.Dispose();
            // Update UI
            BeginInvoke((MethodInvoker) delegate
            {
                int j = 0;
                foreach (TextBox pwBox in tabWords.Controls.OfType <TextBox>())
                {
                    pwBox.Text = Passwords[j];
                    pwBox.Select(0, 0);
                    j++;
                }
            });

            // Unblock the UI Controls.
            Action UnblockUI = () => grpWordsSettings.Enabled = true;

            grpWordsSettings.Invoke(UnblockUI);
        }