Generate a random number and convert it to hex.
Adam Cameron - 30 May 2007 14:18 GMT
> Generate a random number and convert it to hex.
That's not going to help with the G-Z part of the alphabet.
To the OP: why are you trying to do this?
To answer your original question:
1) create a list of valid characters, like you have
2) select a random number between 1 and [length of that list]
3) get the character from the list @ that position and store it in your
result string
4) repeat 2-3 until you have a string of the desired length.

Signature
Adam
JohnGree - 30 May 2007 16:29 GMT
hi Adam, that sound like what i had before, but what is the code to do this?
Dan Bracuk - 30 May 2007 17:35 GMT
[q][i]Originally posted by: [b][b]JohnGree[/b][/b][/i]
hi Adam, that sound like what i had before, but what is the code to do this?
[/q]
The functions randrange and listgetat, combined with the concatonation
operator should work.
Adam Cameron - 30 May 2007 23:51 GMT
> hi Adam, that sound like what i had before, but what is the code to do this?
Sorry mate, I rarely provide code for solutions that really oughtn't be too
far from the grasp of the person needing it. I'm a firm believer in the
"teach a person to fish" approach to problem solving. Call me a b@st@rd if
you like.
Read the docs.
Or post your code here, and we can go through where it could use
modification.

Signature
Adam
Hex is a good call, as it will prevent any *UNFORTUNATE* letter combinations
The code
<cfset rndm = lcase(replace(CreateUUID(), "-", "", "all"))>
<cfoutput>#rndm#</cfoutput>
will generate a random string of 32 characters from the list
a,b,c,...,f,0,1,2,...,9. You can apply a function like left(), right() and so
on, to obtain a shorter string.
is this the code you have 'lost'?:
http://www.cflib.org/udf.cfm?ID=529

Signature
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com