zoukankan
html css js c++ java
初学自定义验证码
protected
void
Page_Load(
object
sender, EventArgs e)
{
System.Drawing.Image img
=
System.Drawing.Image.FromFile(Server.MapPath(
"
Image/a.jpg
"
));
string
txt
=
getVialdata();
System.Drawing.Graphics g
=
System.Drawing.Graphics.FromImage(img);
g.DrawString(txt,
new
Font(
"
宋体
"
,
15
),
new
SolidBrush(Color.Black),
5
,
5
);
Response.ContentType
=
"
Image/Jpeg
"
;
img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
private
string
getVialdata()
{
string
text
=
""
;
Random rand
=
new
Random();
for
(
int
i
=
0
; i
<
5
; i
++
)
{
if
(rand.Next(
100
)
%
2
==
0
)
{
text
+=
(
char
)rand.Next(
'
A
'
,
'
Z
'
);
}
else
{
text
+=
rand.Next(
10
).ToString();
}
}
Session[
"
id
"
]
=
text;
return
text;
}
通过Session["id"]去判断是否输入正确
,
这个送给你!
查看全文
相关阅读:
[LeetCode#252] Meeting Rooms
[LeetCode#247] Strobogrammatic Number II
[LeetCode#265] Paint House II
[LeetCode#256] Paint House
[LeetCode#279] Perfect Squares
[LeetCode#259] 3Sum Smaller
[LeetCode#261] Graph Valid Tree
[LeetCode#271] Encode and Decode Strings
xfsdump的选项-L和-M
Centos7 报错welcome to emergency mode
原文地址:https://www.cnblogs.com/di305449473/p/1239735.html
最新文章
python3 多态与多态性
python3 函数中的反射
python3 面向对象(二)
python3 面向对象(一)
python3 shelve
python3 正则re
time与datetime模块
生成器
nginx 0day漏洞 上传图片可入侵百万台服务器
【转】VC如何调用DLL文件
热门文章
【转】新手入门:关于C++中的内联函数(inline)
【转】socket select函数的详细讲解 by gooer
【转】Java深度历险(九)——Java安全
【转】线程池与工作队列
【转】用 Eclipse 平台的CDT控件进行 C/C++ 开发
【转】Eclipse+CDT+Gcc编译选项控制
C++游戏开发需要阅读的书籍 (转)
Linux现学现用之Top命令
[LeetCode#244] Shortest Word Distance II
[LeetCode#253] Meeting Rooms II
Copyright © 2011-2022 走看看