Here is a custom tag that I use...Hope it helps.
This is how to call it
<cf_randompassword
numberofcharacters="10"
usesymbols="No"
usenumbers="Yes"
useuppercaseletters="No"
uselowercaseletters="Yes">
<!------------------------------------------------------------------------
NAME: cF_RandomPassword
FILE: RandomPassword.cfm
VERSION: 1.0
cREATED: 02/23/1998
LAST MODIFIED: 02/24/1998
AUTHOR: Rob Bilson ([EMAIL PROTECTED])
DEScRIPTION: cF_RandomPassword is a custom cFML tag that allows a user
to generate random passwords for use in their applications.
The parameters governing the creation of the passwords is
fully customizable. Passwords can be of any length and
can contain numbers, symbols, uppercase, and lowercase
letters in any combination. This tag can easily be
incorporated into registration modules to allow for the
automatic generation of random passwords.
cOPYRIGHT: This tag is freeware and can thus be freely used, copied,
modified, and distributed as long as this header is left
intact. Please annotate any changes in the code before
modifying. If you use this tag out on the Internet, I
would appreciate hearing how you are implementing it.
Feel free to e-mail me at: [EMAIL PROTECTED]
DIScLAIMER: No waranties, either expressed or implied are granted
with this software. This program is provided "as is".
The author, Amkor Electronics, and anyone else affiliated
with the creation and use of this tag shall assume no
liability for problems arising out of the use of this tag.
------------------------------------------------------------------------->
<!--- Assign parameters values based on attributes --->
<CFIF isdefined("attributes.NumberOfcharacters")>
<CFIF attributes.numberofcharacters is not "">
<CFSET numberofcharacters=attributes.numberofcharacters>
<CFELSE>
<CFSET numberofcharacters=7>
</CFIF>
<CFELSE>
<CFSET numberofcharacters=7>
</CFIF>
<CFIF isdefined("attributes.UseSymbols")>
<CFIF attributes.usesymbols is not "">
<CFSET usesymbols=attributes.usesymbols>
<CFELSE>
<CFSET usesymbols="No">
</CFIF>
<CFELSE>
<CFSET usesymbols="No">
</CFIF>
<CFIF isdefined("attributes.UseNumbers")>
<CFIF attributes.usenumbers is not "">
<CFSET usenumbers=attributes.usenumbers>
<CFELSE>
<CFSET usenumbers="Yes">
</CFIF>
<CFELSE>
<CFSET usenumbers="Yes">
</CFIF>
<CFIF isdefined("attributes.UseUppercaseLetters")>
<CFIF attributes.useuppercaseletters is not "">
<CFSET useuppercaseletters=attributes.useuppercaseletters>
<CFELSE>
<CFSET useuppercaseletters="Yes">
</CFIF>
<CFELSE>
<CFSET useuppercaseletters="Yes">
</CFIF>
<CFIF isdefined("attributes.UseLowercaseLetters")>
<CFIF attributes.uselowercaseletters is not "">
<CFSET uselowercaseletters=attributes.uselowercaseletters>
<CFELSE>
<CFSET uselowercaseletters="Yes">
</CFIF>
<CFELSE>
<CFSET uselowercaseletters="Yes">
</CFIF>
<CFIF usesymbols is "No" and usenumbers is "No" and useuppercaseletters is
"No" and uselowercaseletters is "No">
<CFSET caller.randompassword="No random password can be generated because
all attributes have a ""No"" Value.">
<CFELSE>
<!--------------------------------------------------------------------------
-
This sets the characters list. If you don't want to use certain
characters, simply remove their corresponding ascii character
number from the appropriate list
----------------------------------------------------------------------------
>
<CFSET
symbols="33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,58,59,60,61,62,63,64,9
1,92,93,94,95,96,123,124,125,126">
<CFSET numbers="48,49,50,51,52,53,54,55,56,57">
<CFSET
uppercaseletters="65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,8
4,85,86,87,88,89,90">
<CFSET
lowercaseletters="97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,1
12,113,114,115,116,117,118,119,120,121,122">
<!--- Begin app --->
<CFSET characterlist="">
<CFSET characterstring="">
<CFIF usesymbols is "Yes">
<CFSET characterlist=listappend(characterlist, symbols, ",")>
</CFIF>
<CFIF usenumbers is "Yes">
<CFSET characterlist=listappend(characterlist, numbers, ",")>
</CFIF>
<CFIF useuppercaseletters is "Yes">
<CFSET characterlist=listappend(characterlist, uppercaseletters, ",")>
</CFIF>
<CFIF uselowercaseletters is "Yes">
<CFSET characterlist=listappend(characterlist, lowercaseletters, ",")>
</CFIF>
<CFSET thelength=listlen(characterlist)>
<CFLOOP index="characterPlaces"
from="1" to="#NumberOfcharacters#">
<CFSET getposition=randrange(1,thelength)>
<CFSET character=listgetat(characterlist, getposition, ",")>
<CFSET characterstring=listappend(characterstring, #chr(character)#,
",")>
</CFLOOP>
<CFSET caller.randompassword=#listchangedelims(characterstring, "")#>
</CFIF>
Doug B.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264629
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4