I got bored...
<cfscript>
function scramble(str)
{
var thisCharSet = 1;
var returnString = str;
var charSets = arrayNew(1);
charSets[1] = '48,57'; // 0-9
charSets[2] = '65,90'; // A-Z
charSets[3] = '97,122'; // a=z
while(thisCharSet lte arrayLen(charSets))
{
for(i=listfirst(charSets[thisCharSet]); i lte
listlast(charSets[thisCharSet]); i=i+1)
{
returnString = replace(returnString, chr(i),
chr(randrange(listfirst(charSets[thisCharSet]),
listlast(charSets[thisCharSet]))), 'all');
}
thisCharSet = thisCharSet + 1;
}
return returnString;
}
</cfscript>
<cfsavecontent variable="txt">
I need to scramble data in a few columns for a demo, so it's not using real
peoples' info. MYSQL 5. I just need to scramble data in one column, then
another so it mixes it all up.
How wouldya go about it?
Thanks,
Will
</cfsavecontent>
<cfoutput>#replace(scramble(txt), '#chr(13)##chr(10)#', '<br />',
'all')#</cfoutput>
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 20, 2007 10:34 AM
To: CF-Talk
Subject: RE: Scrambling data...
<cfset chars = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z" />
<cfset txt = "This is my test string. " />
<cfloop list="#chars#" index="i">
<cfset txt = replace(txt, i, listgetat(chars, randrange(1,
listlen(chars))), 'all') /> </cfloop>
<Cfoutput>#txt#</Cfoutput>
It leaves uppercase as is so words are still capped. You can add those to
the list or add another replace using ucase() but it should suffice for a
demo.
...:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Will Tomlinson [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 20, 2007 7:25 AM
To: CF-Talk
Subject: Scrambling data...
I need to scramble data in a few columns for a demo, so it's not using real
peoples' info. MYSQL 5. I just need to scramble data in one column, then
another so it mixes it all up.
How wouldya go about it?
Thanks,
Will
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies
around the world in government. Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288959
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4