Esempio n. 1
0
        /// <inheritdoc/>
        public override ProtectedString Generate(CryptoRandomStream random, Settings settings)
        {
            if (random == null)
            {
                throw new ArgumentNullException("random" /*nameof(random)*/);
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings" /*nameof(settings)*/);
            }

            var wordlist = GetWordlist(settings);
            var result   = new List <string>();

            do
            {
                result.Add(wordlist[random.Next(0, wordlist.Length)]);
            }while (QualityEstimation.EstimatePasswordBits(string.Join(string.Empty, result.ToArray()).ToCharArray()) < Count);
            return(new ProtectedString(true, string.Join(Separator, result.ToArray())));
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override ProtectedString Generate(CryptoRandomStream random, Settings settings)
        {
            if (random == null)
            {
                throw new ArgumentNullException("random" /*nameof(random)*/);
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings" /*nameof(settings)*/);
            }

            var wordlist = GetWordlist(settings);
            var result   = new List <string>();

            for (uint i = 0; i < Count; i++)
            {
                result.Add(wordlist[random.Next(0, wordlist.Length)]);
            }

            return(new ProtectedString(true, string.Join(Separator, result.ToArray())));
        }