public void Generate()
        {
            using (var gen = new DefaultPasswordGenerator(new CryptoRandomNumberGenerator()))
            {
                var val = gen.Generate(1, TextLength == 0 ? 6 : TextLength, true, true, true, false, null, 2, 2, 2, PasswordStrengthEnum.NotDefined);
                _text = val[0].Value;
            }

            _children.Clear();
            _children.Add(CreateVisual());
            InvalidateVisual();
        }
Ejemplo n.º 2
0
        static void StartGeneration()
        {
            DisplaySelectedArguments();

            Console.WriteLine("Generation started");

            var st = new Stopwatch();

            st.Start();

            Password[] passwords = null;

            try
            {
                using (var gen = new DefaultPasswordGenerator(new CryptoRandomNumberGenerator()))
                {
                    passwords = gen.Generate(count, length, forceNumber, forceLower, forceUpper, useSymbols, dictionary,
                                             minNumber, minLower, minUpper, (PasswordStrengthEnum)minStrength);
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine("ERROR: {0}", exp.Message);
                return;
            }
            finally { st.Stop(); }

            if (string.IsNullOrEmpty(outputfile))
            {
                foreach (var password in passwords)
                {
                    Console.WriteLine(password);
                }
            }
            else
            {
                WritePasswordsToFile(outputfile, passwords);
            }

            Console.WriteLine("Generation finished. Elapsed time : {0}.", st.Elapsed);
        }