Tuesday, August 4, 2009

Simple encryption method in Unix using grep command

You can encrypt text with the "grep" command in Unix. You need a file with lot of junk data, a regular expression that will be the key and the text that needs to be encoded(with one character in each line).

To encode the text do the following steps.

1)grep -f regularexpressionfile junkdatafile1>result1

  • The regularexpressionfile and result1 file should have equal number of lines.
  • regularexpressionfile cant begin with "^".
2)paste texttoencode result1>result2

3)grep -vf regularexpressionfile junkdatafile2>junkdatafile3

4)paste -d"\n" result2 junkdatafile3>encryptedtext

To decode the text do the following

1)grep -f regularexpressionfile encryptedtext|cut -c 1


Anonymous said...

The information here is great. I will invite my friends here.


Anonymous said...

Hello. And Bye.