Asp.net c # color Verification Code Image Generation Program (1/3)

Source: Internet
Author: User

Can color CAPTCHA images defend against attacks by others?
When someone else uses the polling technology to simulate login, he does not know what your verification code is, nor can he obtain it, because this is an image, the computer cannot identify the number in it (unless the interference in the verification code is cracked, the verification code may be read using the relevant image recognition technology. This will not be used here ). If you cannot read the verification code, you will not be able to perform round-robin. Of course, we must first determine whether the verification code is correct in the background to avoid occupying server resources.


3. Random Number code


① Random Number

 

1 /// <summary>
2 // Random Number
3 /// </summary>
4 /// <returns> </returns>
5 private string getrndnum ()
6 {
7 string code = string. empty;
8 random = new random ();
9 for (int I = 0; I <4; I ++)
10 {
11 code = code + random. next (9). tostring ();
12}
13 return code;
14}

② String Random Number

 

1 /// <summary>
2 // string Verification Code
3 /// </summary>
4 /// <returns> </returns>
5 private string getrndstr ()
6 {
7 string vchar = "a, B, c, d, e, f, g, h, I, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z ";
8 string [] vcarray = vchar. split (',');
9 string checkcode = string. empty;
10 random rand = new random ();
11 for (int I = 0; I <4; I ++)
12 {
13 rand = new random (unchecked (int) datetime. now. ticks); // to obtain different random sequences
14 int t = rand. next (vcarray. length); // the exclusive upper bound of the random number to be generated. maxvalue must be greater than or equal to zero, subscript starts from 0
15 checkcode + = vcarray [t];
16}
17 return checkcode;
18}

1 2 3

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.