WELOA.VerificationCode/CheckCode.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Web;
namespace WELOA.VerificationCode
{
public class CheckCode
{
private void checkCodes(string checkCode)
{
int num2;
int width = checkCode.Length * 13;
Bitmap image = new Bitmap(width, 0x17);
Graphics graphics = Graphics.FromImage(image);
graphics.Clear(Color.White);
Color[] colorArray = new Color[] { Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple };
string[] strArray = new string[] { "Verdana", "Microsoft Sans Serif", "Comic Sans MS", "Arial", "宋体" };
Random random = new Random();
for (num2 = 0; num2 < 50; num2++)
{
int x = random.Next(image.Width);
int y = random.Next(image.Height);
graphics.DrawRectangle(new Pen(Color.LightGray, 0f), x, y, 1, 1);
}
for (num2 = 0; num2 < checkCode.Length; num2++)
{
int index = random.Next(7);
int num6 = random.Next(5);
Font font = new Font(strArray[num6], 10f, FontStyle.Bold);
Brush brush = new SolidBrush(colorArray[index]);
int num7 = 4;
if (((num2 + 1) % 2) == 0)
{
num7 = 2;
}
graphics.DrawString(checkCode.Substring(num2, 1), font, brush, (float)(3 + (num2 * 12)), (float)num7);
}
graphics.DrawRectangle(new Pen(Color.Black, 0f), 0, 0, image.Width - 1, image.Height - 1);
MemoryStream stream = new MemoryStream();
image.Save(stream, ImageFormat.Jpeg);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "image/Jpeg";
HttpContext.Current.Response.BinaryWrite(stream.ToArray());
graphics.Dispose();
image.Dispose();
}
public static void DrawImage()
{
CheckCode code = new CheckCode();
HttpContext.Current.Session["CheckCode"] = code.RndNum(4);
code.checkCodes(HttpContext.Current.Session["CheckCode"].ToString());
}
后面还有 24 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
