1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Text;
12 using System.IO;
13 using System.Data.SqlClient;
14
15 publicpartialclassget : System.Web.UI.Page
16 {
17 string ConnectionString ="Server=;uid=;pwd=;database=";
18 protectedvoid Page_Load(object sender, EventArgs e)
19 {
20 char[] charOfAccount ={ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
21 Random account =new Random();
22 StringBuilder sb =new StringBuilder();
23 StringBuilder mm =new StringBuilder();
24 StringBuilder mmmd5 =new StringBuilder();
25 StreamWriter sw =new StreamWriter(@"F:\134.txt", true);
26 sw.WriteLine("帐号 密码 加密之后的密码");
27 for (int i =1; i <=1000; i++)
28 {
29 sb.Remove(0, sb.Length);
30 mm.Remove(0, mm.Length);
31 sb.Append(charOfAccount[account.Next(0, 26)].ToString());//首位,所以只能是字符
32 mm.Append(charOfAccount[account.Next(26, 36)].ToString());
33 for (int j =1; j <10; j++)
34 {
35 sb.Append(charOfAccount[account.Next(0, 36)].ToString());
36 mm.Append(charOfAccount[account.Next(26, 36)].ToString());
37 }
38 try
39 {
40 string pwd = md5(mm.ToString());
41 string sql ="insert into hy(zh,mm)values('"+ sb.ToString() +"','"+ pwd +"')";
42 SqlConnection SqlCon =new SqlConnection(this.ConnectionString);
43 SqlCommand MyCommand =new SqlCommand(sql, SqlCon);
44 SqlCon.Open();
45 if (MyCommand.ExecuteNonQuery() >0)
46 {
47 Response.Write(sb.ToString() +"<br/>");
48 sw.WriteLine(sb.ToString() +""+ mm.ToString() +""+ md5(mm.ToString()));
49 }
50 else
51 {
52 Response.Write("error!<br/>");
53 sw.WriteLine(sb.ToString()+"插入失败!!!!!!!!!!!!!!!!!!!!!!");
54 }
55 SqlCon.Close();
56 }
57 catch (Exception ex)
58 {
59 Response.Write(ex.Message+"<br/>");
60 sw.WriteLine(sb.ToString()+ex.Message);
61 }
62 }
63
64 sw.Close();
65 }
66 publicstring md5(string str)
67 {
68 return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ;
69 }
70 }
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Text;
12 using System.IO;
13 using System.Data.SqlClient;
14
15 publicpartialclassget : System.Web.UI.Page
16 {
17 string ConnectionString ="Server=;uid=;pwd=;database=";
18 protectedvoid Page_Load(object sender, EventArgs e)
19 {
20 char[] charOfAccount ={ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
21 Random account =new Random();
22 StringBuilder sb =new StringBuilder();
23 StringBuilder mm =new StringBuilder();
24 StringBuilder mmmd5 =new StringBuilder();
25 StreamWriter sw =new StreamWriter(@"F:\134.txt", true);
26 sw.WriteLine("帐号 密码 加密之后的密码");
27 for (int i =1; i <=1000; i++)
28 {
29 sb.Remove(0, sb.Length);
30 mm.Remove(0, mm.Length);
31 sb.Append(charOfAccount[account.Next(0, 26)].ToString());//首位,所以只能是字符
32 mm.Append(charOfAccount[account.Next(26, 36)].ToString());
33 for (int j =1; j <10; j++)
34 {
35 sb.Append(charOfAccount[account.Next(0, 36)].ToString());
36 mm.Append(charOfAccount[account.Next(26, 36)].ToString());
37 }
38 try
39 {
40 string pwd = md5(mm.ToString());
41 string sql ="insert into hy(zh,mm)values('"+ sb.ToString() +"','"+ pwd +"')";
42 SqlConnection SqlCon =new SqlConnection(this.ConnectionString);
43 SqlCommand MyCommand =new SqlCommand(sql, SqlCon);
44 SqlCon.Open();
45 if (MyCommand.ExecuteNonQuery() >0)
46 {
47 Response.Write(sb.ToString() +"<br/>");
48 sw.WriteLine(sb.ToString() +""+ mm.ToString() +""+ md5(mm.ToString()));
49 }
50 else
51 {
52 Response.Write("error!<br/>");
53 sw.WriteLine(sb.ToString()+"插入失败!!!!!!!!!!!!!!!!!!!!!!");
54 }
55 SqlCon.Close();
56 }
57 catch (Exception ex)
58 {
59 Response.Write(ex.Message+"<br/>");
60 sw.WriteLine(sb.ToString()+ex.Message);
61 }
62 }
63
64 sw.Close();
65 }
66 publicstring md5(string str)
67 {
68 return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ;
69 }
70 }