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)
{
StringBuilder sb = new StringBuilder();
sb.Append(DateTime.Now.ToString() + "
会员卡号 | 密码 | MD5值 |
" + lstNo[i] + " | ");||
" + lstNo[i] + " | ");" + lstPwd[i] + " | ");" + Encryption(lstPwd[i].ToString(), "MD5") + " | ");
Response.Write(sb.ToString());
}
}
///
/// 生成MD5加密
///
///
///
///
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;
}
//得到随机密码
private static ArrayList GetPwd()
{
ArrayList lst = new ArrayList();
Random rd = new Random();
while (lst.Count < 10000)
{
int r = rd.Next(100000, 999999);
if (!lst.Contains(r))
{
lst.Add(r);
}
}
return lst;
}
//private static ArrayList GetMemberNo()
//{
// ArrayList lst = new ArrayList();
// while (lst.Count < 10000)
// {
// }
// return lst;
//}
//得到用户名
//private static ArrayList GetMemberNo()
//{
// ArrayList lst = new ArrayList();
// Random rd = new Random();
// while (lst.Count < 10000)
// {
// int r = rd.Next(10000000, 99999999);
// if (!lst.Contains(r))
// {
// if (r.ToString().IndexOf("4") == -1 || r.ToString().IndexOf("7") == -1)
// {
// r = rd.Next(10000, 99999);
// }
// else
// {
// lst.Add(r);
// }
// }
// }
// return lst;
//}
}