Help.Web/App_Code/Verify.cs

(开头部分) 3KB

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

//===========================================================
//==                (c)2007 24xN Inc.                      ==
//==         QQ:6458450,Email:qwsf01115@163.com            ==
//==               Site:http://www.24xn.com                ==
//==               论坛:http://bbs.24xn.com                ==
//==                  Code By Xi.Deng                      ==
//==                     版权所有                          ==
//===========================================================
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
/// <summary>
/// Verify 的摘要说明
/// </summary>
public class Verify
{
         /// <summary>
        /// 随机码认证
        /// </summary>
        /// <param name="code">生成认证长度</param>
        public static void DrawImage(int code)
        {
            HttpContext.Current.Session["CheckCode"] = Help.Common.Rand.Number(5);
            CreateImages(HttpContext.Current.Session["CheckCode"].ToString());
        }
        /// <summary>
        /// /// 生成验证图片
        /// /// </summary>
        /// /// <param name="checkCode">验证字符</param>
    private static void CreateImages(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 15);
        System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 30);
        Graphics g = Graphics.FromImage(image);
        g.Clear(Color.LightCyan);
        //定义颜色
        Color[] c = { Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple };
        //定义字体 
        string[] font = { "Verdana", "Microsoft Sans Serif", "Comic Sans MS", "Arial", "宋体", "Comic Sans MS" };
        Random rand = new Random();
        //随机输出噪点
        for (int i = 0; i < 150; i++)
        {
            int x = rand.Next(image.Width);
            int y = rand.Next(image.Height);
            g.DrawPie(new Pen(Color.LightGray, 0), x, y, 6, 6, 1, 1);
        }

        //输出不同字体和颜色的验证码字符
        for (int i = 0; i < checkCode.Length; i++)
        {
            int cindex = rand.Next(7);
            int findex = rand.Next(6);
            Font fs_font = new System.Drawing.Font(font[findex], 14, System.Drawing.FontStyle.Bold);
            Brush b = new System.Drawing.SolidBrush(c[cindex]);
            int ii = 4;
            if ((i + 1) % 2 == 0)
            {
                ii = 2;
后面还有 17 行代码,解锁后查看完整代码

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

AI 解读

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

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