Asp. NET Login Interface User verification code

Source: Internet
Author: User

//ASP. NET user login interface often uses the CAPTCHA code as followsPrivate voidPage_Load (Objectsender, System.EventArgs e) {//Place user code here to initialize the pageLabel4.text=randomnum (4);} Public stringRandomnum (intN//{stringStrchar ="0,1,2,3,4,5,6,7,8,9" ;string[] Vcarray = Strchar. Split (',') ;stringVnum ="" ;//because the string is short, you don't have to StringBuilder.inttemp =-1 ; //record the last random value and try to avoid generating several random numbers//A simple algorithm is used to ensure that the random numbers are generated differently.Random Rand =NewRandom (); for(inti =1; I < n+1; i++ ) { if(Temp! =-1) {Rand=NewRandom (i*temp*unchecked((int) (DateTime.Now.Ticks)) ;} //int t = rand. Next (+);intT=rand. Next (Ten);if(Temp! =-1&& temp = =t) {returnrndnum (n);} Temp=T; Vnum+=vcarray[t];}returnVnum;//returns the generated random number}//' function name: Rndnum//' function parameter: vcodenum--sets the number of digits that return a random string//' function function: a random string that produces a mix of numbers and charactersPrivate stringRndnum (intvcodenum) { stringVchar ="0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,w,x,y,z" ; string[] Vcarray = Vchar.split (",". ToCharArray ());//to generate an array of stringsstringVnum =""; inti; for(i=1; i<vcodenum;i++) {system.random ro=NewRandom ();DoubleDecA =ro. Nextdouble (); Vnum= Vnum + Vcarray[convert.toint32 ( **DecA)]; } //For I=1 to Vcodenum//Randomize//Vnum=vnum & Vcarray (Int (35*rnd)) ' array is generally read from 0, so this is 35*rnd//NextreturnVnum;}//ASP. NET Login Interface user CAPTCHA code, network collection and collation test

Asp. NET Login Interface User verification code

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.