Asp.net 6-bit random code
C # code
<% @ Page Language = "C #" %>
<%
// ----------------------- Random password start ---------------------------
ArrayList MyArray = new ArrayList ();
Random random = new Random ();
String str = null;
// Number of cycles
Int Nums = 6;
While (Nums> 0)
{
Int I = random. Next (1, 9 );
// If (! MyArray. Contains (I ))
//{
If (MyArray. Count <6)
{
MyArray. Add (I );
}
//}
Nums-= 1;
}
For (int j = 0; j <= MyArray. Count-1; j ++)
{
Str + = MyArray [j]. ToString ();
}
// ----------------------- End of random password ---------------------------
Response. Write (str + "my array count -->" + MyArray. Count );
%>
<% @ Page Language = "C #" %>
<%
// ----------------------- Random password start ---------------------------
ArrayList MyArray = new ArrayList ();
Random random = new Random ();
String str = null;
// Number of cycles
Int Nums = 6;
While (Nums> 0)
{
Int I = random. Next (1, 9 );
// If (! MyArray. Contains (I ))
//{
If (MyArray. Count <6)
{
MyArray. Add (I );
}
//}
Nums-= 1;
}
For (int j = 0; j <= MyArray. Count-1; j ++)
{
Str + = MyArray [j]. ToString ();
}
// ----------------------- End of random password ---------------------------
Response. Write (str + "my array count -->" + MyArray. Count );
%>
Code of 6-digit random numbers in asp
Asp code
<%
'----------------------- Random password start ---------------------------
Randomize
FreeMember = Int (999999 * Rnd) + 1) 'method 1
Function makePassword (maxLen) 'method 2, the generated Random Code contains letters
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
WhatsNext = Int (1-0 + 1) * Rnd + 0)
If whatsNext = 0 Then
'Character
Upper = 90
Lower = 65
Else
Upper = 57
Lower = 48
End If
StrNewPass = strNewPass & Chr (Int (upper-lower + 1) * Rnd + lower ))
Next
MakePassword = strNewPass
End Function
'Freember = makePassword (6)
'----------------------- Random password termination ---------------------------
FreeMember = int (999999-100000 + 1) * RND + 100000) 'method 3
Response. Write FreeMember & "my array count -->" & len (freember)
%>
From chenliang1234576