You won't be able to produce valid colors with this as colors are hexadecimal numbers and you are producing strings with letters greater than F
RANDOM PASSWORD GENERATOR SCRIPT!
I know there is a random password tutorial here
already. This is just another way to do the same. I think this is a little
easier to understand.
Plus, it has other application! Not that its useful?.Nevertheless?..
YOU CAN GENERATE BACKGROUND COLORS WITH IT. Try to use the outputs as
<table bgcolor="stpassword">
(stpassword ?in this particular case. You will call it something more logical
obviously !)
<html>
<head>
<title>Password Generator !</title>
</head>
<body>
<!--- Start a new structure here --->
<cfset ststring=structNew()>
<!--- since this is a 6 character password. And because
color needs HEX code ....loop it 6 times --->
<cfloop index="i"
from="1" to="6"
step="1">
<!--- let ?a? be random number
between 48 and 122. Thus this will include everything from 0 to 9, Capital A to
Z and small case a to z. --->
<cfset a = randrange(48,122)>
<!--- This is where the stucture is
populated, Conceptually, ststring is a new structure specified
above....ststring1 is key 1, ststring2 is key 2, ststring3 is key 3, and so on
--->
<!--- since all characters between
57 and 65 and those between 90 and 97 are charachters like "[,],+,=,..,$,#" and
so on, we don't need them. Unless ofcourse yours is a password with special
characters. That explains the condition below. If our randrange givers a number
like 92, we don't need it and I chose to subtitue it with an "E"...you can use
your own substitution. --->
<cfif (#a# gt 57 and #a# lt 65) or (#a#
gt 90 and #a# lt 97)>
<cfset ststring["#i#"]="E">
<cfelse>
<cfset ststring["#i#"]=#chr(a)#>
</cfif>
</cfloop>
<!--- Now that our password is made up of 6 stings, it is just a question of
putting that together, thus ... --->
<cfset stpassword ="#ststring[1]##ststring[2]##ststring[3]##ststring[4]##ststring[5]##ststring[6]#">
<!--- In principle, take each variable in a string of
six, and assign a character to it which falls between 48 to 57 or 65 to 90 or 97
to 122 --->
Randomly Generated Password : <b><cfoutput>#stpassword#</cfoutput></b>
<!--- let me know if you think of any improvements on this one --->
</body>
</html>
You won't be able to produce valid colors with this as colors are hexadecimal numbers and you are producing strings with letters greater than F
Hey,
Thanks for the start, I might suggest a slightly more random function. The code below eliminates the need for your "E" substitution.