Exemple #1
0
        /// <summary>
        /// Generates a new secure password.
        /// </summary>
        /// <returns>New secure password.</returns>
        public static string GetRandomSecurePassword()
        {
            double         Entropy  = 0;
            PasswordPolicy PWPolicy = new PasswordPolicy(15, 18);

            // Don't allow the following characters:     | *$£-+_&=%/\^~#@
            // (because the 'british pound' character doesn't exist on every keyboard!)
            PWPolicy.CharacterSetRemove("AO");

            PasswordGenerator PWGenerator = new PasswordGenerator(PWPolicy);

            // NOTE: An Entropy of 91 was deemed sufficient in 2016 but it should be raised in future years to accommodate
            // the increase in computing power (CPU and GPU) and advance of parallel processing and hence the lessening of
            // time it would take to break a password of such an Entropy.
            while (Entropy < 91)
            {
                PWGenerator.GeneratePassword();
                Entropy = PWGenerator.PasswordEntropy;
            }

            return(PWGenerator.Password);
        }