c#生成图片验证码,避免被软件识别的完美方案
图片生成与随机数生成函数
1 /// <summary>
2 /// 生成随机码
3 /// </summary>
4 /// <param name="length">随机码个数</param>
5 /// <returns></returns>
6 private string CreateRandomCode(int length)
7 {
8 int rand;
9 char code;
10 string randomcode = String.Empty;
11
12 //生成一定长度的验证码
13 System.Random random = new Random();
14 for (int i = 0; i < length; i++)
15 {
16 rand = random.Next();
17
18 if (rand % 3 == 0)
19 {
20 code = (char)(A + (char)(rand % 26));
21 }
2 /// 生成随机码
3 /// </summary>
4 /// <param name="length">随机码个数</param>
5 /// <returns></returns>
6 private string CreateRandomCode(int length)
7 {
8 int rand;
9 char code;
10 string randomcode = String.Empty;
11
12 //生成一定长度的验证码
13 System.Random random = new Random();
14 for (int i = 0; i < length; i++)
15 {
16 rand = random.Next();
17
18 if (rand % 3 == 0)
19 {
20 code = (char)(A + (char)(rand % 26));
21 }
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,
部分文章来自网络,