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
Tayo Akinmade added
arrayTrim
4 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)