[ articles ][ Scramble/Descramble a file using PERL ]

This method should not be considered encryption. Heck, under the right conditions, the file will just be transposed.

I saw something similar to this in a high-school-intro-to-encryption type book. basically this goes through each line in a file and reorders the whole file by looping through and pulling every 3 characters (or however many you specify), and reconstructs the file.

Its really just something to have fun with. Unless you are using it in a high-tech computer flick. Then you can use this for getting access to any government organization's mainframe... :)

Usage:

sencrypt.pl [input_filename] [output_filename] [wordlength]

output_filename defaults to input_filename prefixed with "encrypted"
wordlength defaults to 3

sdecrypt.pl [input_filename] [output_filename] [wordlength]

output_filename defaults to input_filename prefixed with "decrypted"
wordlength defaults to 3

Example:

Input - text1.txt:

ABCDEFGHIJ
KLMNOPQRST
UVWXYZ

Running "sencrypt.pl text1.txt" results in the file encryptedtext1.txt:

ADGJLOR
WZBEH
MPSUXCFIKNQTVY

Running "sdecrypt.pl encryptedtext1.txt" results in the file decryptedencryptedtext1.txt:

ABCDEFGHIJ
KLMNOPQRST
UVWXYZ
Notes:

sencrypt.pl and sdecrypt.pl are just the reverse of each other if you use the same wordlength for both of them. in other words, you could just as well run sdecrypt.pl first, and use sencrypt.pl to unscramble the file. therefore, you should be able to run these multiple times, and as long as you run the other one the same number of times, their effects will cancel each other, and you should be left with the original file.

You may get wierd results on binary files, or files with non-alphanumeric characters.

Setting wordlength to 1 does not change the file. The same is true if wordlength is greater than the number of characters in the file.

You need perl installed on your system to run these scripts.

THE CODE
this takes a file and scrambles it:

sencrypt.pl
this script takes a file and descrambles it:

sdecrypt.pl

i'm beginning to wonder if there is any use for this. a secret decoder ring would be just about as effective.

questions? comments? please send an e-mail.