If I use the -e option when running the program everything works OK. When I try the -d option I get the line telling me to "Use -e to encrypt or -d to decrypt". I'm sure it's something simple that I'm missing or left out. Any ideas?
#!/usr/bin/perl -w
use Crypt::RC4;
use Getopt::Std;
system('clear');
getopts('ed:', \%opts);
if ($opts{e})
{
print "Enter Passphrase: ";
chomp ($passphrase = <stdin>);
print "Enter Plaintext: ";
chomp ($plaintext = <stdin>);
$encrypted = RC4 ( $passphrase, $plaintext );
$passphrase = "";
print "Enter the file name to save to:";
chomp ($filename = <stdin>);
print "Encrypting........\n";
open(FILE,">$filename");
print FILE $encrypted;
close FILE or die "There was an error closing the file\n";
} elsif ($opts{d})
{
print "option e not used\n";
} else{
print "Use -e to encrypt or -d to decrypt\n";
}
"The Universe is not only more complex than we imagine, it is more complex than we can imagine." - Albert Einstein
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.