Home | Libraries | Submit | Tools | Resources | About the Project | RSS
 

 randStr

randStr(strLen, charset)

Author: Bobby Hartsfield (Send Email)
Library/Category: StrLib/Misc
Required CF Version: ColdFusion 5
Version: 2
Last Updated: April 2, 2007
Rating: 5.00 out of 5 based on 1 ratings.

Description
randStr returns a randomly generated string using lowercase letters, and/or numbers and possible uppercase letters.

The length of the string can be set specifically or the function can choose a random length within a specified range. eg: "8,16" will generate a string 8 to 16 characters long: "5" would only generate strings with 5 characters.

The characters used are based on your own preference. You may build a 'charset' using any of the three words "alpha, numeric, and upper".

Alpha = a-z Upper = A-Z Numeric = 0-9

Download this UDF
View this UDF

Parameters
Name Description Required
strLen Either a number of a list of numbers representing the range in size of the returned string. Yes
charset A string describing the type of random string. Can contain: alpha, numeric, and upper. Yes

Return Values
Returns a string.

Example
<cfoutput>
#randStr("8,16", "alphanumericupper")#
</cfoutput>




   !     Search
Google
Web www.cflib.org

Advanced Search





   !     Log On

Email Address

Password

Auto Logon

Register today and start using our advanced features such as commenting and UDF rating.

There are currently 68 active sessions on CFLib.org.



   !     Latest Additions
These are the latest functions that have been updated or added to CFLib.org.

arrayFind
structToQueryRow
nowTimestamp
toSeconds
amInCFThread

More...