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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|