ajax -项目/VailidImg.aspx.cs

(开头部分) 2KB

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

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Drawing;
using Common;

public partial class VailidImg : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        string checkCode = CreateCode(4);

        //用于验证
        Session[Checks.vcode] = checkCode;
        CreateImages(checkCode);
    }

    /*产生验证码*/
    public string CreateCode(int codeLength)
    {

        string so = "2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
        string[] strArr = so.Split(',');
        string code = "";
        Random rand = new Random();
        for (int i = 0; i < codeLength; i++)
        {
            code += strArr[rand.Next(0, strArr.Length)];
        }
        return code;
    }

    /*产生验证图片*/
    public void CreateImages(string code)
    {

        Bitmap image = new Bitmap(60, 26);
        using (Graphics g = Graphics.FromImage(image))
        {
            WebColorConverter ww = new WebColorConverter();
            g.Clear((Color)ww.ConvertFromString("#eeeeee"));

            Random random = new Random();
            //画图片的背景噪音线
            for (int i = 0; i < 12; i++)
            {
                int x1 = random.Next(image.Width);
                int x2 = random.Next(image.Width);
                int y1 = random.Next(image.Height);
                int y2 = random.Next(image.Height);

                g.DrawLine(new Pen(Color.LightGray), x1, y1, x2, y2);
后面还有 29 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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