RandomizeString(theString, theLength)
Last updated May 9, 2009
Version: 0 | Requires: ColdFusion 5 | Library: StrLib
Description:
Pass in a string and I'll return a randomized string value at the length you desire.
Return Values:
returns a string
Example:
Parameters:
| Name | Description | Required |
|---|---|---|
| theString | string of text to randomize | Yes |
| theLength | length of random string to create | Yes |
Full UDF Source:
<!---
I generate a randomized string of desired length.
@param theString string of text to randomize (Required)
@param theLength length of random string to create (Required)
@return returns a string
@author Stephen Withington (steve@stephenwithington.com)
@version 0, May 9, 2009
--->
<cffunction name="RandomizeString" returntype="string" output="false" access="public"
hint="pass me a string and desired length and i'll randomize it for you.">
<cfargument name="theString" type="string" required="true" default="0123456789ABCDEF" />
<cfargument name="theLength" type="numeric" required="true" default="32" />
<cfset var randomizedString = "" />
<cfset var theIndex = "" />
<cfloop index="theIndex" from="1" to="#val(arguments.theLength)#" step="1">
<cfset randomizedString = randomizedString & mid(arguments.theString, rand()*len(arguments.theString)+1, 1) />
</cfloop>
<cfreturn randomizedString />
</cffunction>
Search CFLib.org
Latest Additions
Alan McCollough added
forceBoolean
5 day(s) ago
Shawn Porter added
DeMoronize
8 day(s) ago
Chris Carey added
readPropertiesFi...
8 day(s) ago
Randy Johnson added
lastDayofWeek
11 day(s) ago
Top Rated
indentXml
Rated 5.0, 4 time(s)
QuickSort
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)