Earlier today, I was talking about the clever SPAM mail I got; it used randomly inserted characters to prevent anti-spam engines from matching banned words while at the same time keeping the text human-readable. This made me think of that popular email that went around a while back that demonstrated that as long as the first and last letters of each word were kept in place, the rest of the letters could be shuffled and it would still be human-readable (for the most part).
Here is the example that made the email rounds:
Aoccdrnig to rscheearch at Cmabrigde uinervtisy, it deosn't mttaer waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteres are at the rghit pclae. The rset can be a tatol mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod as a wlohe.
I had some time at lunch and thought it would be fun to turn this into a ColdFusion user defined function: GarbleText(). This takes one argument, the target text, and shuffles the letters of each word, leaving the first and last letter of each word the same. Therefore, the only words that will be shuffled will be those consisting of at least 4 letters:
(first:1 letter)(middle: 2+ letters)(last:1 letter)
I perform this using Java regular expressions and the special character set: \w (word characters). This means that in addition to first and last letters, all punctuation will be kept in the same place (as it is not considered a word character.
Here is the GarbleText() ColdFusion user defined function:
Launch code in new window » Download code as text file »
Taking this ColdFusion UDF, we can then pass in some text to get a garbled response:
Launch code in new window » Download code as text file »
Running the above code, we get this garbled output:
Tihs is quite ebnraasrsimg to adimt, but I have been tltloay ckhniceg you out form aroscs the room. I don't thnik taht I have eevr seen aynnoe look so alamgziny sxey in a dress lkie that. It's not like me to just come out and say shnoitemg to that ecfeft, but your lges, your cveurs, yuor btuaey - I seem to be unalbe to cootrnl mlesyf.
Fun times. Try out the GarbleText() UDF for yourself.
Download Code Snippet ZIP File
Comments (1) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
RELoop ColdFusion Custom Tag To Iterate Over Regular Expression Patterns
New SPAM Leverages Amazing Brain Functionality
Tkhnas for sahring tihs ilecbirdny uslsees fcuitnon wtih the rset of the cfiolosudn wolrd. I am srue my clehdirn wlil lvoe it.
Posted by Michael Evangelista on Sep 24, 2007 at 9:49 PM