Yes, piping the output to a file results in the same as printing to the file.
So it looks like the terminal does that.
Here is the code for the whole script:
#!/usr/bin/env perl
use strict;
use Crypt::Rijndael;
use MIME::Base64;
my $string = 'QeTEv2804';
sub encrypt {
my ($plaintext) = @_;
my $password = "uNsY3WSs0hTd";
my $trail = 16 - (length($plaintext) % 16 );
$plaintext .= "\0" x $trail;
my $cipher = Crypt::Rijndael->new(pack("A32",$password),Crypt::Rijnd
+ael::MODE_CBC());
$cipher->set_iv(pack("A16",$password));
my $crypted = $cipher->encrypt($plaintext);
my $encoded = encode_base64($crypted);
return $encoded;
}
sub decrypt {
my ($ciphertext) = @_;
my $password = "uNsY3WSs0hTd";
my $cipher_nonbase64 = decode_base64($ciphertext);
my $cipher = Crypt::Rijndael->new(pack("A32",$password),Crypt::Rijnd
+ael::MODE_CBC());
$cipher->set_iv(pack("A16",$password));
my $plaintext = $cipher->decrypt($cipher_nonbase64);
return $plaintext;
}
my $enc = &encrypt($string);
my $dec = &decrypt("$enc");
print "Decrypted --> $dec <--\n";
Pipe the script to file and you should see it. |