Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Create Random Passwords

Status
Not open for further replies.

TwoOdd

Programmer
Sep 10, 2003
196
CL
Here is what I have used to generate random alpha numeric passwords automatically. The ending result is a 6 character password that is numeric, alpha, numeric, alpha, numeric, alpha. You can add more variables if the password needs to be longer.

<%
'Declare variables
Dim a
Dim b
Dim c
Dim x
Dim y
Dim z
Dim Alphabet
Dim p_password

'Generate 6 random numbers - the first three between 1 and 9, the last three between 1 and 26
randomize
a = int(rnd*9)+1
b = int(rnd*9)+1
c = int(rnd*9)+1
x = int(rnd*26)+1
y = int(rnd*26)+1
z = int(rnd*26)+1

'Assign the last three numbers to letters in the alphabet
Alphabet = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;

'x, y, and z are the alpha characters. So whatever number came up for each variable, we'll take the associated letter in the alphabet string.

x = mid(Alphabet, x, 1)
y = mid(Alphabet, y, 1)
z = mid(Alphabet, z, 1)

'Set password to the 6 variables that were just created. You can put them in whatever order you want. I alternated because there is a chance of spelling inappropriate words if you put all three letters together -- trust me it happened to me! :) That's why I alternated them.

p_password = a & x & b & y & c & z

%>


Good Luck

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Is this a test? What about this I came up with to create a somewhat pronounceable password.

vowelarray=array(&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;e&quot;,&quot;e&quot;,&quot;e&quot;,&quot;e&quot;,&quot;i&quot;,&quot;i&quot;,&quot;i&quot;,&quot;o&quot;,&quot;o&quot;, &quot;o&quot;,&quot;u&quot;,&quot;u&quot;,&quot;y&quot;)
middlearray=array(&quot;ai&quot;,&quot;au&quot;,&quot;ay&quot;,&quot;ea&quot;,&quot;ee&quot;,&quot;eu&quot;,&quot;ia&quot;,&quot;ie&quot;,&quot;io&quot;,&quot;oa&quot;,&quot;oi&quot;,&quot;oo&quot;,&quot;oy&quot;)
consonantarray=array(&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;g&quot;,&quot;h&quot;,&quot;l&quot;,&quot;m&quot;,&quot;n&quot;,&quot;p&quot;,&quot;r&quot;,&quot;s&quot;,&quot;t&quot;)
endarray=array(&quot;th&quot;,&quot;st&quot;,&quot;sh&quot;,&quot;ph&quot;,&quot;ng&quot;,&quot;nd&quot;)

randomize

intrand=int(12*rnd)
stingstart=consonantarray(intrand)
intrand=int(13*rnd)
stringmiddle1=middlearray(intrand)
intrand=int(12*rnd)
stringmiddle2=consonantarray(intrand)
intrand=int(16*rnd)
stringmiddle3=vowelarray(intrand)
intrand=int(6*rnd)
stringend=endarray(intrand)
response.write stingstart & stringmiddle1 &stringmiddle2 & stringmiddle3 & stringend

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top