CFLib.org – Common Function Library Project

Jumble(str)

Last updated December 16, 2001

author

Brad Roberts

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Takes a string and scrambles the characters in a random fashion. If no string is given, it scrambles the default string (numbers 1-10).

Return Values:
Returns a string.

Example:

<cfset string="coldfusion">

<cfoutput>
The scrambled string is: #jumble(string)#<BR>
</cfoutput>

Parameters:

Name Description Required
str String you want to jumble. Yes

Full UDF Source:

/**
 * Takes a string and scrambles the characters.
 * 
 * @param str      String you want to jumble. 
 * @return Returns a string. 
 * @author Brad Roberts (broberts@nxs.net) 
 * @version 1, December 16, 2001 
 */
function jumble(str) {
  var tempstring=""; 
  var temp=0;
  while (len(str) gt 0) {
    temp = randrange(1, len(str));
    tempstring = tempstring & mid(str, temp, 1);
    str = removechars(str, temp, 1);
  }
  return tempstring;
}

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

Created by Raymond Camden / Design by Justin Johnson