#!/usr/bin/perl -w use strict; use diagnostics; use Crypt::RC4; #grab command line args and get keyphrase my $key_phrase = $ARGV[0]; my $cleartext_file = $ARGV[1]; my $cyphertext_file = $ARGV[2]; chomp($key_phrase); #define some variables my $plaintext; my $cyphertext; my $plaintext2; #complain if mis-used if ($#ARGV <2) { die "Usage crypt_file.pl "; } #open the plaintext file open INFILE, "<$cleartext_file" or die "Can't open input file: ",$cleartext_file,"\n"; my $cph_in = new Crypt::RC4($key_phrase); undef $/; #$plaintext = ; close(INFILE); $plaintext = "This is a test\n with a line-break in it\n"; print the plaintext to check it print "+++++++++++++++plain text+++++++++++++++++++++++\n"; print $plaintext; $cyphertext = $cph_in->RC4($plaintext); my $cph_out = new Crypt::RC4($key_phrase); $plaintext2 = $cph_out->RC4($cyphertext); open OUTFILE, ">$cyphertext_file"; print OUTFILE $cyphertext; print "\n----------------cypher text---------------------\n"; print $cyphertext; close(OUTFILE); print "\n++++++++++++++plain text again +++++++++++++++++\n"; print $plaintext2;