473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

3 letter and 3 number random password generator

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.
Nov 21 '05 #1
4 3476

"David Eadie" <ha*****@hotmail.com> wrote in message
news:da**************************@posting.google.c om...
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
Nov 21 '05 #2
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.

Nov 21 '05 #3
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/de...classtopic.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
Nov 21 '05 #4
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.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe | last post by:
Hi, I have been working on some code that requires a high use of random numbers within. Mostly I either have to either: 1) flip a coin i.e. 0 or 1, or 2) generate a double between 0 and 1. I...
70
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like...
5
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible...
3
by: tshad | last post by:
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
4
by: darrel | last post by:
I can grab a random number in vb.net like this: Dim RandomClass As New Random Dim RandomNumber As Integer RandomNumber = RandomClass.Next(1, 26) However, what I want is a random number. Short...
73
by: cesco | last post by:
I have to generate a list of N random numbers (integer) whose sum is equal to M. If, for example, I have to generate 5 random numbers whose sum is 50 a possible solution could be . Is there a...
2
by: RYAN1214 | last post by:
How can I use this random password code, and then insert the password into email which is sent to the user after the registration has been finished? thx <html> <head> <title>Javascript:...
20
by: A | last post by:
Hi all. Is this a bug or what??? here is a simple code: <?php mt_srand(1); echo mt_rand(0, 255)."<br />"; echo mt_rand(0, 255)."<br />";
8
by: remlostime | last post by:
i use g++ to generater rand number, now i find that the RAND_MAX is 32367 in my computer, how can i make a bigger rand number( the number is wihin in the integer(2^32-1))
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.