Random text --> Mdxrtt Eano
August 19, 2010 5:20 PM

I'm looking for a program that will take a block of text, mix up the characters in the block, and then spit a mixed up block with the exact same character count. Where would I find such a thing?
posted by codacorolla to Computers & Internet (12 answers total) 1 user marked this as a favorite
Same place you'd find everything else, in a Perl one-liner:

echo -n "Random Text" | perl -MList::Util -e 'print List::Util::it //,do{local $/=<>})'
posted by Zed at 5:28 PM on August 19, 2010


Ack. Cut and paste mangling.

echo -n "Random Text" | perl -MList::Util -e 'print List::Util::shuffle(split //,do{local $/=<>})'
posted by Zed at 5:28 PM on August 19, 2010


I'm not sure what to do with that.
posted by codacorolla at 5:37 PM on August 19, 2010


tr ccxtitntxk whl omtW,clghuccaickaetitlk b ,eltepe diebotosnhhtcro mo tarw a uppiexii?thdadeecahgce t alp iut arelo'I hoaamnm enoorhu grs e k ixas ea h r fuawalrtthIm nfn.cfhobsk dn

ruoge yoH!e
posted by sonic meat machine at 5:50 PM on August 19, 2010


For that Perl command you'd need Perl installed on your system...

http://www.perl.org/

...and then you could just do it in a command window. There is also probably a way to do it in PowerShell, which is built into Windows 7 and available for most other flavors of Windows.

The above web site might also be just what you need, however. :)
posted by Luciferous at 5:56 PM on August 19, 2010


A python four-liner (just for fun):

>>> import random
>>> text = list("Arbitrary Text")
>>> random.shuffle(text)
>>> print ''.join(text)
reyrrattTAi xb
posted by sonic meat machine at 6:12 PM on August 19, 2010


Depends on what you mean by mix up... The Perl and the web link are very literal, (and the web version slightly broken depending on how you look at it). They treat the newlines at the end of a line as just another character, this may be what you want, but can lead to really weird things.
abc
def
ghi
can become:
a


bcdefghi
where the newline characters just happen to hit a run all at once. Same count, but maybe not what you want. The web version will even take 2 lines as input, implicit 2 newlines on the ends, then give you 3 lines back... the 2 real given newlines and once extra implicit on the third line.
hello
there
becomes:
hell
oth
ere
You may want something more 'looks like original' where there are the same number of lines of about the same length (even distribution of newlines) and you might want to prevent runs of other characters (multiple spaces/punctuation). All while keeping the same ending character counts. You may want to go word by word and shuffle the characters in words and words themselves and arrange to have the same number of lines and/or words per line.

Can you be more specific?
posted by zengargoyle at 6:15 PM on August 19, 2010


What do you want to do this for? If you just need to count characters, and you don't need to preserve the per-letter counts in your text (that is: if there are 8 A's in the original, there must be 8 A's in the random text) you could just do a successive find-and-replace in Word. Replace all instances of 'b' with 'a', 'c' with 'a', and so on. Do it enough and it'll turn into gibberish.
posted by Xany at 6:37 PM on August 19, 2010


FYI, when you want to slurp the entire input into $_ you can use -0777 in combination with -n, so you can shorten it to perl -MList::Util -0777ne 'print List::Util::shuffle split //'
posted by Rhomboid at 6:59 PM on August 19, 2010


I'm still playing around with this:
that I posted last night

Mixing up different parts of the bitmap in wordpad produces mixed results, but seems to corrupt the file less often if the new version has the same number of characters in it.

The isnoop.net link works pretty well at producing multi-colored static into an image.
posted by codacorolla at 7:11 PM on August 19, 2010


I hadn't thought of using find and replace, but replacing one gibberish character with another gets pretty good results too, thanks Xany.
posted by codacorolla at 7:18 PM on August 19, 2010


Well, multi-colored static is what you are going to get if you randomly shuffle the characters of a bitmap file. If you get something else, your method was insufficiently random.

I think what you may be looking for is the ability to algorithmically change specific bytes. In that case, you really need to learn to program. That's not as daunting as it sounds; look into Python, which has good documentation and a great community. you could do a lot simply by learning basic file I/O.
posted by sonic meat machine at 7:20 PM on August 19, 2010


« Older How to Keep two PCs Synched   |   How did a paper towel get in my crank case? Newer »
This thread is closed to new comments.