#!/usr/bin/perl use strict; use IO::Handle; # $Platon: encoder.pl,v 1.5 2002/04/10 13:11:26 jombik9 Exp $ ############################################################################# # # # This script is intended do decrypt STDIN and write that to STDOUT. # # # # =Nepto= # # Wolcano # # Method syntax : # # # # if (is_decodable_input) { } # # # # In output of we switch the (START|END)_STR to indicate # # succesfull decoding... # # # # Changes: # # # # 23-03-2001 creation (Neptun & Wol) # # 26-03-2001 changed ENCODE_1 start and end strings (Wol) # # 27-03-2001 removed UPPER,LOWER encoding (Wol) # # 29-03-2001 added auto_encode_1 detection and auto_use # # @heh# ############################################################################# # System init. select(STDERR); $| = 1; # make unbuffered select(STDOUT); $| = 1; # make unbuffered # constants/variables. my $START_ENCODE_1_STR = '123'; my $END_ENCODE_1_STR = '321'; my $START_AUTO_ENCODE_1_STR = '%'; my $END_AUTO_ENCODE_1_STR = '%'; my $AUTO_ENCODE_1_PREFIX = ''; my $START_SWITCH_CASE_STR = 'aAbBcC'; my $END_SWITCH_CASE_STR = 'CcBbAa'; =pot print '-' x 60, "\n"; print(STDERR "Encoder starts...\n"); print(STDERR "To use encode shortcuts, specify by: %%\n"); print(STDERR " then use \" \" to encode \n"); printf(STDERR "To decode use: %s %s\n", $START_ENCODE_1_STR, $END_ENCODE_1_STR); printf(STDERR "To switch case of use: %s %s\n", $START_SWITCH_CASE_STR, $END_SWITCH_CASE_STR); print '-' x 60, "\n"; =cut while () { # chomp; # detect autoencryption prefix flags and put the command into PREFIX if ($_ =~ /^($START_AUTO_ENCODE_1_STR)(.*)($END_AUTO_ENCODE_1_STR)(.*)$/) { $AUTO_ENCODE_1_PREFIX = $2; # remove the PREFIX flags and continue $_ = $2 . $4 . "\n"; } # if INPUT starts with PREFIX we add the encode flags to the rest of the STR if (!($AUTO_ENCODE_1_PREFIX eq '') && ($_ =~ /^($AUTO_ENCODE_1_PREFIX)(.*)$/)) { $_ = $AUTO_ENCODE_1_PREFIX . $START_ENCODE_1_STR . ' ' . $2 . ' ' . $END_ENCODE_1_STR . "\n"; } # ENCODE METHOD no. 1 (shift characters right according to position on keyboard) if ($_ =~ /^(.*)($START_ENCODE_1_STR)(.*)($END_ENCODE_1_STR)(.*)$/) { my $buf; $buf = $3; $buf =~ y/-abcdefghijklmnopqrstuvwxyz`,.;'[]ABCDEFGHIJKLMNOPQRSTUVWXYZ~<>:"{}123456789=0/=snvfrghjokl;,mp[wtdyibecuxz.`'a]qSNVFRGHJOKL:~"A}Q2345678901-/; # otocime START a END . $_ = $1 . $4 . $buf . $2 . $5 . "\n"; } # DECODE METHOD no. 1 elsif ($_ =~ /^(.*)($END_ENCODE_1_STR)(.*)($START_ENCODE_1_STR)(.*)$/) { my $buf; $buf = $3; $buf =~ y/-abcdefghijklmnopqrstuvwxyz`,.;'[]ABCDEFGHIJKLMNOPQRSTUVWXYZ~<>:"{}1234567890=/0'vxswdfguhjknbio]earycqzt`.m,l;p["VXSWDFGUHJKNBIO}EARYCQZT~>M