ASP. NET logon interface user verification code

Source: Internet
Author: User

// The following code is frequently used in the ASP. Net user logon interface:

Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
Label4.text = randomnum (4 );
}
Public String randomnum (int n )//
{
String strchar = ";
String [] vcarray = strchar. Split (',');
String vnum = "";
// Stringbuilder is not required because the string is short.
Int temp =-1;
// Record the last random value to avoid the generation of several identical random numbers.
// Use a simple algorithm to ensure different random numbers are generated
Random Rand = new random ();
For (INT I = 1; I <n + 1; I ++)
{
If (temp! =-1)
{
Rand = new random (I * temp * unchecked (INT)

Datetime. Now. ticks ));
}
// Int T = Rand. Next (35 );
Int T = Rand. Next (10 );
If (temp! =-1 & temp = T)
{
Return rndnum (N );
}
Temp = T;
Vnum + = vcarray [T];
}
Return vnum; // return the generated random number.
}
// ''Function name: rndnum
// ''Function parameter: vcodenum -- set the number of digits returned to a random string
// ''Function: generate a random string mixed with numbers and characters
Private string rndnum (INT vcodenum)
{
String vchar = ", 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 (); // generate an array of strings
String vnum = "";
Int I;
For (I = 1; I <vcodenum; I ++)
{
System. Random RO = new random ();
Double Deca = Ro. nextdouble ();
Vnum = vnum + vcarray [convert. toint32 (35 * DECA)];
}
// For I = 1 to vcodenum
// Randomize
// Vnum = vnum & vcarray (INT (35 * RND) ''array is generally read from 0, so here it is 35 * RND
// Next
Return vnum;
}

// The user verification code on the ASP. Net Logon interface. Collect and test the code on the network.
// Http://www.weste.net/2006/2-24/14492415770.html
// Http://www.webdn.com/web_file/program/asp.net/0602080581/

 

 

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.