Beispiel #1
0
        public JsonResult EmailNotifyForChangePwd(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(Json(new { code = OperationResultType.Error, message = Msg_ChangPwd_Notify + "失败,邮箱不能为空" }));
            }
            var verifyCode = VerificationCodeHelper.Create(VerifyCodeLength, false);

            if (!verifyCode.Check())
            {
                return(Json(new { code = OperationResultType.Error, message = Msg_ChangPwd_Notify + "失败,生成验证码时错误" }));
            }
            //验证码以及生成时间写入session
            Session.Set(KEY_Session_VerifyCode_ChangePwd, verifyCode.Code);
            Session.Set(KEY_Session_VerifyCode_ChangePwd_BeginTime, DateTime.Now);

            //调用验证码通知器
            VerifyCodeEmailNotifyer notifier = new VerifyCodeEmailNotifyer();

            notifier.Notify(verifyCode.Code, email);

            return(Json(new
            {
                code = OperationResultType.Success,
                message = string.Format("验证码已发送到您的邮箱,有效期{0}分钟,请及时查收。", VerifyCodeExpireTime)
            }));
        }
Beispiel #2
0
    private void GetValidateGraphic(string verificationCode)
    {
        Texture2D t = new Texture2D(8, 8);

        t.LoadImage(VerificationCodeHelper.CreateValidateGraphic(verificationCode));
        Sprite sprite = Sprite.Create(t, new Rect(0, 0, 64, 27), Vector2.zero);

        verificationCodeImage.sprite = sprite;
    }
        /// <summary>
        /// 验证码
        /// </summary>
        /// <returns></returns>
        public ActionResult GetVerificationCode()
        {
            string verificationCode = VerificationCodeHelper.CreateVerificationText(4);
            Bitmap _img             = VerificationCodeHelper.CreateVerificationImage(verificationCode, 95, 30);

            _img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            TempData["VerificationCode"] = verificationCode.ToUpper();
            return(null);
        }
Beispiel #4
0
        public ActionResult GetVerifycationCode()
        {
            var verifyCode = VerificationCodeHelper.Create(VerifyCodeLength);

            if (!verifyCode.Check())
            {
                return(null);
            }
            Session.Set(KEY_Session_VerifyCode_Login, verifyCode.Code);
            return(File(verifyCode.ImageBytes, @"image/jpeg"));
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            //http://api2-287.zcgsrg.com:65/cloud/api.do?pa=captcha.next&key=94824340
            var imgPath = $"{AppDomain.CurrentDomain.BaseDirectory}safeCode.jpg";

            var code = VerificationCodeHelper.GetCode(imgPath, "123");

            Console.WriteLine(code);

            Console.ReadKey();
        }
Beispiel #6
0
        public async Task OnGet()
        {
            var urlbase = $"{Request.Scheme}://{Request.Host}";

            Click = await VerificationCodeHelper.GetClickCodeDataAsync(urlbase);

            Puzzle = await VerificationCodeHelper.GetPuzzleCodeDataAsync(urlbase);

            Slider = await VerificationCodeHelper.GetSliderCodeDataAsync(urlbase);

            Arithmetic = await VerificationCodeHelper.GetArithmeticImageCodeDataAsync(urlbase);

            String = await VerificationCodeHelper.GetStringImageCodeDataAsync(urlbase);
        }
Beispiel #7
0
 private void GetValidateCode(int length)
 {
     verificationCode = VerificationCodeHelper.CreateRandomCode(length);
 }
Beispiel #8
0
 /// <summary>
 /// бщжЄТы
 /// </summary>
 /// <returns></returns>
 public IActionResult VCode()
 {
     byte[] byteValues = VerificationCodeHelper.RefreshLoginCode();
     return(File(byteValues, "image/jpeg"));
 }