3 letter and 3 number random password generator

  • Thread starter Thread starter David Eadie
  • Start date Start date
D

David Eadie

G'Day all,
I cant work out how to create a random password generator.
In specific the password (or well the output as a string) needs to be
in the following format:

abc123

So no capitals or other characters, Just the first three being letters
and the last three being numbers in random. Basically im creating a
list if these to write to a text file (I can do that part :-) )

I have googled and come across many examples but none that will help
me.
Any ides?
Dave.
 
David Eadie said:
G'Day all,
I cant work out how to create a random password generator.
In specific the password (or well the output as a string) needs to be
in the following format:

abc123

So no capitals or other characters, Just the first three being letters
and the last three being numbers in random. Basically im creating a
list if these to write to a text file (I can do that part :-) )

I have googled and come across many examples but none that will help
me.
Any ides?
Dave.

Does this help?

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Randomize()
End Sub

Function GetPWD() As String
Dim sRet As String
sRet = Chr(Int((Asc("z") - Asc("a") + 1) * Rnd + Asc("a")))
sRet = sRet & Chr(Int((Asc("z") - Asc("a") + 1) * Rnd + Asc("a")))
sRet = sRet & Chr(Int((Asc("z") - Asc("a") + 1) * Rnd + Asc("a")))

sRet = sRet & CStr(Int(9 * Rnd()))
sRet = sRet & CStr(Int(9 * Rnd()))
sRet = sRet & CStr(Int(9 * Rnd()))

Return sRet
End Function

It's as simple as you can get (I think) but doesn't guarantee a unique value.

Jim Edgar
 
Hi Jim,
It works great although I cant understand how it does it.. (But
anyways...)
Now you said that you cant garantee the unique value, why is that? Is
it because there is
a chance of there being an identical value or is it a code specific
thing that might cause it?
If you get a few mins spare (or anyone :-) ) would you be able to make
a little sence of the code to me? (Ie. How it operates through its
stages.)
Im still learning .net and this would be soo appreciated!!
Cheers
Dave.
 
Hack,

Even when you use the Guid uniqness cannot be guaranteed when it is not
tested against an collection of existing ones.

http://msdn.microsoft.com/library/d...n-us/cpref/html/frlrfsystemguidclasstopic.asp

In this page is the text
A GUID is a 128-bit integer (16 bytes) that can be used across all computers
and networks wherever a unique identifier is required. Such an identifier
has a very low probability of being duplicated.

I hope this gives some idea's

Cor
 
Hi Cor and thanks for your time,
I have read about GUID's before, just not on the MS site.
The code that I have supplied will create about 9300 random passwords
for me, which is about 4 time more then I need at any one time for a
bulk import into active directory.
Cheers mate :-)

Dave.
 

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

Back
Top