I wrote a custom tag that does this:
<CF_RANDOMSTRING LENGTH = "12" CHARSTART = "1" CHAREND = "z" OUTPUTVARIABLE="myString">
generates a pseudo random string of specified length containing only characters found between the ascii values of CHARSTART and CHAREND
<CFPARAM NAME="Attributes.Length" DEFAULT="12"> <CFPARAM NAME="Attributes.CharStart" DEFAULT="1"> <CFPARAM NAME="Attributes.CharEnd" DEFAULT="z"> <CFPARAM NAME="Attributes.OutputVar" DEFAULT="RandomString">
<CFSCRIPT> result = "";
for(i=1;i LT Attributes.Length;i=i+1){ result = result & Chr(RandRange(Asc(Attributes.CharStart),Asc(Attributes.CharEnd))); }
SetVariable("Caller.#Attributes.OutputVar#",result); </CFSCRIPT>
P.
-----Original Message----- From: Chris Martin [mailto:chrism@fsenablers.com] Sent: Thursday, May 03, 2001 5:38 PM To: CF-Talk Subject: RE: Random Password
Here's one I got off this list a while ago. Props to whoever wrote it, because its helped me out a few times.
<cfscript> random_word = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1); random_word = random_word & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandRange(1,26), 1);
password = "#random_word##RandRange(1000,9999)#"; </cfscript>
<cfoutput>PASSWORD: <b>#password#</b></cfoutput>
it will generate a password with 7 random letter and a 4 digit number.
-----Original Message----- From: Chris Badouin [mailto:chris@theeverydaypeople.com] Sent: Thursday, May 03, 2001 12:24 PM To: CF-Talk Subject: Random Password
All-
Sorry I am pressed for time today, but does any one have script for generating random passwords?
CB