473,757 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3501

"David Eadie" <ha*****@hotmai l.com> wrote in message
news:da******** *************** ***@posting.goo gle.com...
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.EventArg s) 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
7380
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 have utilised the following random number source code http://www.agner.org/random/ What I have found is that there is a problem with seeding. The code generates a seed based on time(0). I have found that I need to increment
70
6274
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 using the high-order bits returned by rand() instead of the low-order bits, avoiding using rand() for anything that wants decently random numbers, not using rand() if you want more than approx. UINT_MAX total different sequences, and so on. So I...
5
3353
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 double value in the range could come up with equal probability). I'd also like to be able to seed this generator (e.g., via the clock) so that the same sequence of random values don't come up every time. Anybody have an easy and fast...
3
2191
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
2396
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 of making a case statement with 26 options, is there a more streamlined way to get an integer between 1-26 translated into one of the letters?
73
3218
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 simple pattern or function in Python to accomplish that? Thanks and regards Francesco
2
1973
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: Password Generator</title> <style type="text/css"> input, select { font-family: Verdana, Arial, sans-serif;
20
5133
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
4730
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
9297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.