RandomizeString(theString, theLength)
Last updated May 09, 2009
Version: 0 | Requires: CF5 | 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:
<cfoutput>#RandomizeString("0123456789ABCDEF", 32)#</cfoutput>
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
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016