Sometimes the internal Web site to the user to initialize the bulk of the password, in batch generation of passwords, by a random function is the time as the seed (MS level), a large number of generated password process 1ms will produce the same password 10 or so, (if the US-level repeat problem may be resolved, But as if the PC doesn't seem to be working, there is no such option: It has been modified to use the string of username and the product of time as the seed, so that the random password generated will not be repeated, and the type of password can be freely chosen. Randomly generate passwords
public static string Createrandompassword (bool Isnumber, bool isletter, int length, string seed)
... {
String passWord = "";
int randomnumber = 0;
char code;
int i = 0;
int seedint = 0;
int pip = Convert.ToInt32 (DateTime.Now.Millisecond.ToString ());
if (seed. Trim (). Length > 0)
... {
Converts a string to an integral type
int seedlength = seed. Length;
char[] Seedchar = new Char[seedlength];
for (i = 0; i < seedlength; i++)
... {
Seedchar[i] = Convert.tochar (seed. Substring (i, 1));
Seedint = Seedint + Convert.ToInt32 (seedchar[i));
}
Pip = Seedint * PIP;
}
System.Random Random = new Random (PIP);
Generate only numeric passwords
if (Isnumber = = True && Isletter = = False)
... {
for (i = 0; i < length; i++)
... {
Randomnumber = random. Next ();
Code = (char) (' 0 ' + (char) (randomnumber% 10));
PassWord = PassWord + code. ToString ();
}
}
Generate only alphabetic passwords
else if (Isnumber = = False && Isletter = = True)
... {
for (i = 0; i < length; i++)
... {
Randomnumber = random. Next ();
if (randomnumber% 2 = 0)
... {
Code = (char) (' A ' + (char) (randomnumber% 26));
PassWord = PassWord + code. ToString ();
}
Else
... {
Code = (char) (' A ' + (char) (randomnumber% 26));
PassWord = PassWord + code. ToString ();
}
}
}