Example #1
0
 /// <summary>
 /// Возвращает каптчу и устанавливает ее ключ в сессию текущего контекста
 /// </summary>
 /// <returns></returns>
 public ActionResult RegCaptcha()
 {
     var builder = new XCaptcha.ImageBuilder()
     {
         Canvas = new DefaultCanvas()
         {
             Width = 115,
             Height = 37
         }
     };
     var captcha = builder.Create(new Random(System.Environment.TickCount).Next(65535).ToString());
     Session.Add("reg_captcha", captcha.Solution);
     return new FileContentResult(captcha.Image, captcha.ContentType);
 }
Example #2
0
        /// <summary>
        /// Create the captcha
        /// </summary>
        /// <returns></returns>
        private CaptchaResult CreateCaptcha()
        {
            CotecnaCanvas ourCanvas = new CotecnaCanvas();
            CotecnaTextStyle ourTextStyle = new CotecnaTextStyle();
            CotecnaProvidedNoise ourNoise = new CotecnaProvidedNoise();
            CotecnaDistort ourDistort = new CotecnaDistort();

            XCaptcha.ImageBuilder builder = new XCaptcha.ImageBuilder(6, ourCanvas, ourTextStyle, ourDistort, ourNoise);

            //Create a 6 letter captcha
            return builder.Create();
        }