This is actually not a problem. In general, there will be no problems. The Code is as follows:
Private string random_str (INT length)
{
Int number;
String checkcode = string. empty;
Int iseed = 10;
Random RO = new random (10 );
Long tick = datetime. Now. ticks;
Random random = new random (INT) (tick & 0 xffffffffl) | (INT) (tick> 32 ));
For (INT I = 0; I <length; I ++)
{
Number = random. Next ();
Number = Number % 36;
If (number <10)
{
Number + = 48;
}
Else
{
Number + = 55;
}
Checkcode + = (char) Number). tostring ();
}
Return checkcode;
}
But if you have a stomachache, this will not work.
Random_str (4) + random_str (4) + random_str (4)
You will generate 12 new characters which are actually three identical strings, so there are countless Trojans in your mind.
In fact, adding a sleep will solve this problem:
Private string random_str (INT length)
{
System. Threading. thread. Sleep (1 );
Int number;
String checkcode = string. empty;
Int iseed = 10;
Random RO = new random (10 );
Long tick = datetime. Now. ticks;
Random random = new random (INT) (tick & 0 xffffffffl) | (INT) (tick> 32 ));
For (INT I = 0; I <length; I ++)
{
Number = random. Next ();
Number = Number % 36;
If (number <10)
{
Number + = 48;
}
Else
{
Number + = 55;
}
Checkcode + = (char) Number). tostring ();
}
Return checkcode;
}
Essentially closer to real random