Random number/letter generator

T

tshad

Is there a good random number/letter generator out there?

I just want to be able to generate a password that has letters and or
numbers about 10 characters long.

Thanks,

Tom
 
K

Kevin Spencer

How about System.Random?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
B

Brock Allen

How about System.Random?

I don't think this implementation is sufficient for cryptographic purposes.
Check out System.Security.Cryptography.RandomNumberGenerator and the RNGCryptoServiceProvider
implementation.
 
T

tshad

Brock Allen said:
I don't think this implementation is sufficient for cryptographic
purposes. Check out System.Security.Cryptography.RandomNumberGenerator and
the RNGCryptoServiceProvider implementation.

I'll check that out.

What I came up with temporarily was:

**********************************************************
Function RandomNumber(min as Integer, max as Integer) as integer
Dim random as Random = new Random()
RandomNumber = random.Next(min, max)
End Function

Function RandomString(size as integer, lowerCase as boolean) as string
Dim builder as StringBuilder = new StringBuilder()
Dim random as Random = new Random()
Dim i as integer
dim ch as char

for i = 0 to size -1
ch = Convert.ToChar(Convert.ToInt32(25 * random.NextDouble() + 65))
random.NextDouble()
builder.Append(ch)
next
if(lowerCase) then RandomString = builder.ToString().ToLower()

RandomString = builder.ToString()
end function
****************************************************************

I would then do the following:

Dim builder as StringBuilder = new StringBuilder()
builder.Append(RandomString(6, false))
builder.insert(3,RandomNumber(0, 10))

password1.text = builder.ToString()

This seems to do what I want, at least for now.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top