Generating random number of fixed-size
-
Hi, I want to generate a random number of fixed-size for passwords. The size of the password must be 8 digits. I'm using c#, .net 1.1 Cheers Gerry.
Random rand = new Random();
string pwd = rand.Next(10000000, 99999999).ToString();that should do the trick.
| Website: http://www.onyeyiri.co.uk | Sonork: 100.21142 : TheEclypse | "If a dolar was a chicken would the chicken be evil?"
-
Hi, I want to generate a random number of fixed-size for passwords. The size of the password must be 8 digits. I'm using c#, .net 1.1 Cheers Gerry.
Create an int array of size 8, and assign a random number(range 0 to 9) for each int. Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
Random rand = new Random();
string pwd = rand.Next(10000000, 99999999).ToString();that should do the trick.
| Website: http://www.onyeyiri.co.uk | Sonork: 100.21142 : TheEclypse | "If a dolar was a chicken would the chicken be evil?"
DUH :-O I thought of doing that with int, but the size would be too large. So I thought of using an int array Should've thought of using string instead ::Incredibly embarrased:: Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
DUH :-O I thought of doing that with int, but the size would be too large. So I thought of using an int array Should've thought of using string instead ::Incredibly embarrased:: Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twainbut the two parameters sent to Random.Next are int's, i checked the max value of int's just a minute ago using the Int32.MaxValue property, and it had more than 8 digits in it, i only converted it to string because it was a password.
| Website: http://www.onyeyiri.co.uk | Sonork: 100.21142 : TheEclypse | "If a dolar was a chicken would the chicken be evil?"
-
but the two parameters sent to Random.Next are int's, i checked the max value of int's just a minute ago using the Int32.MaxValue property, and it had more than 8 digits in it, i only converted it to string because it was a password.
| Website: http://www.onyeyiri.co.uk | Sonork: 100.21142 : TheEclypse | "If a dolar was a chicken would the chicken be evil?"
I'm just embarassing myself more and more, aren't I? :-O For a minute there, I was using Int16 ?!?! Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain -
Create an int array of size 8, and assign a random number(range 0 to 9) for each int. Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
Get your facts first, and then you can distort them as much as you please Mark Twain