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