Example #1
0
 public ApiV1Controller(PooledEntropyCprngGenerator terninger
                        , PasswordRatingService ratingService
                        , PasswordStatisticService statisticService
                        , IpThrottlerService ipThrottler
                        , DictionaryService dictionaryService)
 {
     _Terninger         = terninger;
     _RatingService     = ratingService;
     _StatisticService  = statisticService;
     _IpThrottler       = ipThrottler;
     _DictionaryService = dictionaryService;
 }
        [OutputCache(Duration = 60 * 60)]       // Cache for one hour.
#endif
        public ActionResult Combinations(int?l)
        {
            IpThrottlerService.IncrementUsage(IPAddressHelpers.GetHostOrCacheIp(this.HttpContext.Request), 1);

            // Return information about the number of combinations as a JSON object.
            var result = new JsonCombinationContainer();
            var length = Math.Min(l.HasValue ? l.Value : DefaultLength, MaxLength);

            result.combinations  = Math.Pow(Characters.Length, length);
            result.combinations -= (double)Blacklist.Value.Count(x => x.Length == l);       // Remove blacklist entries.
            result.rating        = PasswordRatingService.RatePin(result.combinations);
            return(new JsonNetResult(result));
        }
 public ApiV1AlphaNumericController(PooledEntropyCprngGenerator terninger, PasswordRatingService ratingService, PasswordStatisticService statisticService, IpThrottlerService ipThrottler, DictionaryService dictionaryService)
     : base(terninger, ratingService, statisticService, ipThrottler, dictionaryService)
 {
 }
 public ApiV1UnicodeController(PooledEntropyCprngGenerator terninger, PasswordRatingService ratingService, PasswordStatisticService statisticService, IpThrottlerService ipThrottler, DictionaryService dictionaryService
                               , IMemoryCache memoryCache)
     : base(terninger, ratingService, statisticService, ipThrottler, dictionaryService)
 {
     _MemoryCache = memoryCache;
 }