static void Main(string[] args)
        {
            int    numWords     = 4;
            string wordListFile = "English";
            string curArg       = "";

            try
            {
                foreach (string arg in args)
                {
                    curArg = arg;

                    // length arg is number of words in phrase
                    if (arg.StartsWith("/length:", StringComparison.OrdinalIgnoreCase))
                    {
                        numWords = Int16.Parse(arg.Substring(8));
                    }
                    // multi-lang allows for a randomly choosen word file
                    else if (arg.StartsWith("/lang:", StringComparison.OrdinalIgnoreCase))
                    {
                        if (arg.Length == 6)
                        {
                            throw new ArgumentException();
                        }

                        wordListFile = arg.Substring(6);
                    }
                    else
                    {
                        throw new ArgumentException();
                    }
                }
            }
            catch
            {
                Console.WriteLine("Invalid Parameter: " + curArg);
                Console.WriteLine(GetUsage(Console.BufferWidth));
                return;
            }

            PasswordGenerator.WordListPath = WordListPath;
            Console.WriteLine(PasswordGenerator.Generate(numWords, wordListFile));
        }
Example #2
0
 private void GenerateButton_Click(object sender, EventArgs e)
 {
     PassphraseText.Text = PasswordGenerator.Generate(NumWordsTrackbar.Value, RandomLanguageCheckbox.Checked ? "*" : LanguageCombo.Text);
 }