Exemplo n.º 1
0
        public FileContentResult Code(int type)
        {
            string code = CodeUtil.GetSingleObj().CreateVerifyCode(CodeUtil.VerifyCodeType.MixVerifyCode, 6);
            //LogUtil.Info($"生成6位验证码:{code}");
            bool isAddLines = false;

            if (type == 1)
            {
                isAddLines = true;
            }
            var bitmap = CodeUtil.GetSingleObj().CreateBitmapByImgVerifyCode(code, 100, 40, isAddLines);

            code = EncryptUtil.EncryptDES(code, AprilConfig.SecurityKey);
            CookieUtil.AddString("code", code, 5);
            MemoryStream stream = new MemoryStream();

            bitmap.Save(stream, ImageFormat.Gif);
            return(File(stream.ToArray(), "image/gif"));
        }