I am having an issue with the below script. The intent of the script is to input an encryption key and a text file and then use the TEA algorithm to encrypt the contents. For whatever reason, my code or the module is failing to work properly with a text file that contains more than 32 characters before a line break. I am not real sure how to fix this, I was hoping someone could help me out. Thanks in advance.
#!/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; open (my $fh, '<', $file) or die $!; my @input = readline($fh) or die "readline failed: $!\n"; if ($action eq '-e') { my @cryptedText = cryptText($key,$action,\@input); my $i = join("\n",@cryptedText); print $i; } if ($action eq '-d') { my @cryptedText = cryptText($key,$action,\@input); my $i = join('',@cryptedText); print $i; } sub cryptText { die if @_ != 3; my ($key,$action,$input) = @_; my @cryptedText; foreach my $text (@$input) { if ($action eq '-d') { $text = decrypt($text,$key); } if ($action eq '-e') { $text = encrypt($text,$key); } push (@cryptedText,$text); } return @cryptedText; }

In reply to 32 Character limit by z662

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.