Tuesday 21 April 2009

How to generate randam string of 8 characters

|start cfscript|

RPassword = "";
// Get the random characters for password

RandomCharacters=1;

for (RandomCharacters;RandomCharacters < 8; RandomCharacters++ )
{
//character code from A To Z
ranPassword = RandRange(0097,0122);
RPassword = ListAppend(RPassword, CHR(ranPassword));
}

//Get the random numbers from 1 to 9 for password

RPassword = ListAppend(RPassword,RandRange(1,9));

//Get rid of commas

RPassword = Replace(RPassword,',','', 'all');

|end cfscript|

No comments: