示例#1
0
 public ActionResult Index(CaptchaModel captchaModel, string SimleText, string Description)
 {
     //To verify the captcha call the CaptchaHelper.Verify.(CaptchaModel)
     //as a parameter to transfer the CaptchaModel.
     if (CaptchaHelper.Verify(captchaModel))
     {
         return
             Content(string.Format("CAPTCHA is valid.<br/>Your Model:<br/>{0}<br/>{1}:", SimleText,
                                   Description));
     }
     
     return Content("CAPTCHA is invalid");
 }
示例#2
0
        /// <summary>
        /// Check for proper input captcha
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool Verify(CaptchaModel model)
        {
            try
            {
                var encryptorModel = GetEncryptorModel();

                if (encryptorModel == null)
                {
                    return false;
                }

                var textDecrypt = Encryption.Decrypt(model.CaptchaDeText, encryptorModel.Password, encryptorModel.Salt);
                return textDecrypt == model.CaptchaInputText;
            }
            catch
            {

                return false;
            }
           
        }