コード例 #1
0
        internal static PasswordStrengthEvaluator Create(int n, IProbabilisticPasswordModel model)
        {
            var t = new List <double>(n + 1)
            {
                double.MaxValue
            };

            for (var i = 1; i <= n; ++i)
            {
                var samplePassword    = model.GenerateSamplePassword();
                var sampleProbability = model.CalculateProbability(samplePassword);
                t.Add(sampleProbability);
            }

            var a = new SearchableList <double>(t, DescendingComparer <double> .Instance);

            var c = new List <double>(n + 1)
            {
                0
            };

            for (var i = 1; i <= n; ++i)
            {
                c.Add(c[i - 1] + 1 / (n * a[i]));
            }

            return(new PasswordStrengthEvaluator(model, a, c));
        }
コード例 #2
0
 internal PasswordStrengthEvaluator(IProbabilisticPasswordModel model, SearchableList <double> a, IReadOnlyList <double> c)
 {
     _model = model;
     _a     = a;
     _c     = c;
 }