Perl scripts to encrypting and decrypt text using Rijndael


I talked about Rijndael in a few previous posts: Expressing a function f: GF(2⁸) → GF(2⁸) as a polynomial using a Lagrange polynomial, Generating the Rijndael S-box, Efficient multiplication and division in GF(28), Sieving irreducible monic polynomials over a finite field, Addition and multiplication table for GF(22).

Today I wrote a couple of Perl scripts which use off-the-shelf CPAN modules to encrypt and decrypt text using a passphrase. For ease of transport, at the cost of some storage space, the encrypted payload is Base64 encoded.

The particular CPAN modules in question are Crypt::CBC and Crypt::Rijndael.

encrypt.pl and decrypt.pl source in my GitHub repository. They operate on STDIN and produce output on STDOUT.

Note that if you pass an incorrect passphrase to decrypt.pl you get garbage output, rather than an error.

I attach a secret message which is encoded with the passphrase “hunter2”.

encrypted.txt

Comments (0)

Skip to main content