YongHu_UI/Model/CaptchaGenerator.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Web;

namespace YongHu_UI.Model
{
    public class CaptchaGenerator
    {
        #region 私有字段

        public string Text { get; private set; }
        public Bitmap Image { get; private set; }
        private int LetterCount { set; get; }  // 验证码位数
        private int Type { set; get; }
        private int letterWidth = 16;  // 单个字体的宽度范围
        private int letterHeight = 20; // 单个字体的高度范围
        private static Random Random = new Random(~unchecked((int)DateTime.Now.Ticks));
        private Font[] fonts =
        {
            new Font(new FontFamily("Times New Roman"),10 + Random.Next(1),FontStyle.Regular),
            new Font(new FontFamily("Georgia"), 10 + Random.Next(1),FontStyle.Regular),
            new Font(new FontFamily("Arial"), 10 + Random.Next(1),FontStyle.Regular),
            new Font(new FontFamily("Comic Sans MS"), 10 + Random.Next(1),FontStyle.Regular)
        };

        #endregion

        #region 构造器

        /// <summary>
        /// 实例化 <see cref="T:AiXiu.Common.CaptchaGenerator"/> 类的一个新实例,默认为4个数字长度
        /// </summary>
        public CaptchaGenerator()
        {
            //HttpContext.Current.Response.Expires = 0;
            //HttpContext.Current.Response.Buffer = true;
            //HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            //HttpContext.Current.Response.AddHeader("pragma", "no-cache");
            //HttpContext.Current.Response.CacheControl = "no-cache";
            LetterCount = 4;
            Type = 0;
            InitText();
            CreateImage();
        }

        /// <summary>
        /// 指定数字长度实例化 <see cref="T:AiXiu.Common.CaptchaGenerator"/> 类的一个新实例
        /// </summary>
        /// <param name="Length">Length.</param>
        public CaptchaGenerator(int Length)
        {
            //HttpContext.Current.Response.Expires = 0;
            //HttpContext.Current.Response.Buffer = true;
            //HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            //HttpContext.Current.Response.AddHeader("pragma", "no-cache");
            //HttpContext.Current.Response.CacheControl = "no-cache";
            LetterCount = Length;
后面还有 138 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。