自动生成会员卡号和密码
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;
//}
}
转载于:https://www.cnblogs.com/yongheng178/archive/2010/12/22/1913530.html
推荐阅读
- 暴君公司|暴君公司 第十八章 做会员吗
- Java代码辅助效率工具Lombok(注解|Java代码辅助效率工具Lombok(注解,自动生成代码)
- 给AACTP创始会员的一封信(发于只有十位会员的创会期)
- 滴滴乘客端会员理解
- 彦彦(想大力发展书店会员,你得学好这个大招!)
- 创造良好的新习惯,实现人生的终极梦想—为什么“樊登读书”、“得到”app的vip会员还要参加“三七读书会”
- 这是我充铜牌会员的第三天
- Omegagroup会员真实感受?Omega造血能力强、公司有实力!
- JPA大坑 ,无法像mybaits一样在current_at字段,自动生成创建时间
- ModStartCMS模块化万能建站系统v3.0.0|ModStartCMS模块化万能建站系统v3.0.0 会员VIP、访问控制、URL兼容