Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
64 Points
639 Posts
Jan 08, 2008 06:25 AM|LINK
public class PwCreator { public string Creator( ) { String Vchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z"; String[] VcArray = Vchar.Split(','); String VNum = ""; Random random = new Random(); for (int i = 1; i <= 6; i++) { int iNum = 0; while ((iNum = Convert.ToInt32(VcArray.Length * random.NextDouble())) == VcArray.Length) { iNum = Convert.ToInt32(VcArray.Length * random.NextDouble()); } VNum += VcArray[iNum]; } return VNum; } }
the password Must mixed numbers and letters and can't have same char
when I test this code the problem is sometimes password is numbers or letters only ... just can't find out how to modify it can you please help?
and also.. how to avoid a same numbers or same letters appear in password?
thank you
jcjcjc
Member
64 Points
639 Posts
When Random a string set how to avoid same char appear? thank you
Jan 08, 2008 06:25 AM|LINK
public class PwCreator { public string Creator( ) { String Vchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z"; String[] VcArray = Vchar.Split(','); String VNum = ""; Random random = new Random(); for (int i = 1; i <= 6; i++) { int iNum = 0; while ((iNum = Convert.ToInt32(VcArray.Length * random.NextDouble())) == VcArray.Length) { iNum = Convert.ToInt32(VcArray.Length * random.NextDouble()); } VNum += VcArray[iNum]; } return VNum; } }the password Must mixed numbers and letters and can't have same char
when I test this code the problem is sometimes password is numbers or letters only ... just can't find out how to modify it can you please help?
and also.. how to avoid a same numbers or same letters appear in password?
thank you