Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Data. sqlclient;
Using system. text;
Using system. collections;
Public partial class memberno: system. Web. UI. Page
{
Arraylist lstno = getno ();
Arraylist lstpwd = getpwd ();
Protected void page_load (Object sender, eventargs E)
{
String SQL = string. empty;
Sqlconnection con = new sqlconnection ("Data Source = 192.168.1.178; user id = sa; Password = myth; database = test ;");
Sqlcommand COM = new sqlcommand ();
COM = con. createcommand ();
Con. open ();
If (! Ispostback)
{< br> stringbuilder sb = new stringbuilder ();
Sb. append (datetime. now. tostring () + "
"); Sb. append ("
membership card number |
password |
MD5 value |
");
for (INT I = 0; I <10000; I ++)
{< br> // sb. append (" " + lstno [I] + "");
Sb. append (" " + lstno [I] + "");
Sb. append ("" + lstpwd [I] + "");
Sb. append ("" + encryption (lstpwd [I]. tostring (), "MD5") + "");
Sb. append ("");
SQL = "insert into memberno (userid, password, MD5) values (" + lstno [I]. tostring () + ", '" + lstpwd [I]. tostring () + "','" + encryption (lstpwd [I]. tostring (), "MD5") + "')";
Com. commandtext = SQL;
Com. executenonquery ();
}
SB. append ("</table> ");
Response. Write (sb. tostring ());
}
}
/// <Summary>
/// Generate MD5 Encryption
/// </Summary>
/// <Param name = "password"> </param>
/// <Param name = "format"> </param>
/// <Returns> </returns>
Public static string encryption (string password, string format)
{
Password = password. Trim ();
Return System. Web. Security. formsauthentication. hashpasswordforstoringinconfigfile (password, Format). Trim ();
}
Public static arraylist getno ()
{
Arraylist lst = new arraylist ();
Int NO = 88800887;
While (lst. Count <10000)
{
If (No. tostring (). indexof ("4") <0 & No. tostring (). indexof ("7") <0)
{
Lst. Add (NO );
}
No ++;
}
Return lst;
}
// Obtain the Random Password
Private Static arraylist getpwd ()
{
Arraylist lst = new arraylist ();
Random RD = new random ();
While (lst. Count <10000)
{
Int r = RD. Next (100000,999 999 );
If (! Lst. Contains (r ))
{
Lst. Add (R );
}
}
Return lst;
}
// Private Static arraylist getmemberno ()
//{
// Arraylist lst = new arraylist ();
// While (lst. Count <10000)
//{
//}
// Return lst;
//}
// Obtain the user name
// Private Static arraylist getmemberno ()
//{
// Arraylist lst = new arraylist ();
// Random RD = new random ();
// While (lst. Count <10000)
//{
// Int r = RD. Next (10000000,999 99999 );
// If (! Lst. Contains (r ))
//{
// If (R. tostring (). indexof ("4") =-1 | r. tostring (). indexof ("7") =-1)
//{
// R = RD. Next (10000,999 99 );
//}
// Else
//{
// Lst. Add (R );
//}
//}
//}
// Return lst;
//}
}