生成一个8到15位随机密码
/// <summary>
/// 获取一个8到15位的随机密码
/// </summary>
/// <returns></returns>
private string GetRandomPwd()
{
StringBuilder Vchar = new StringBuilder();
Vchar.Append("0,1,2,3,4,5,6,7,8,9,");//数字
Vchar.Append("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,");//小写字母
Vchar.Append("A,B,C,D,E,F,G,H,I,G,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,");//大写字母
Vchar.Append("_,*,@,#");//特殊字符
string[] VcArray = Vchar.ToString().Split(',');
string VNum = "";
Random rand = new Random();
int minPwd = rand.Next(8, 16);//随机生成的密码长度(7-15)
for (int i = 1; i < minPwd; i++)
{
int t = rand.Next(VcArray.Length);
VNum += VcArray[t];
}
return VNum;
}