#!/usr/bin/perl -w use strict; use warnings; use Crypt::Tea; if (@ARGV != 3) { print STDERR "Usage: $0 [-d|-e] [FILENAME] [KEY] \n"; exit 1; } if (($ARGV[0] ne '-d') && ($ARGV[0] ne '-e')) { print "Specify '-d' to decrypt or '-e' to encrypt\n"; exit 1; } my ($action, $file, $key) = @ARGV; my $input; { open (my $fh, '<', $file) or die $!; binmode($fh); local $/; $input = <$fh>; } if ($action eq '-e') { print encrypt($input,$key); } if ($action eq '-d') { print decrypt($input,$key); }