sub crypto { my $file = shift; my $action = shift; my $op = $action eq 'encrypt' ? '>' : '<'; my $suffix = $action eq 'encrypt' ? '.aes' : ''; my $fh; open($fh, "$op:via(PerlIO::via::CBC)", "$file$suffix"); if ($action eq 'encrypt') { open(SOURCE, '<', $file) or die $!; print $fh $_ while(sysread(SOURCE, $_, 1024)); close SOURCE; } else { open PLAIN, '>', "$file.jpg" or die $!; print PLAIN <$fh>; close PLAIN or die $!; } close $fh; return 1; } 1;