Crypt::Rijndael::PP - Pure Perl Implementation of the Rijndael Encryption Algorthim
use Crypt::Rijndael::PP; # Please use securely generated keys and IV's, these are purely examples!!! my $key = 'A' x 32; my $input = 'B' x 16; # For you hardcore low level 'I want to control everything!' types: { my $iv = 'A' x 16; # If you aren't sure which mode to use, use CBC (Chaining Block Cipher) my $cipher = Crypt::Rijndael::PP->new( $key, Crypt::Rijndael::PP::MODE_CBC() ); $cipher->set_iv( $iv ); my $cipher_text = $cipher->encrypt( $input ); my $plain_text = $cipher->decrypt( $cipher_text ); } # For you, 'do it for me' types: { my $cipher = Crypt::CBC->new( -key => $key, -cipher => 'Rijndael::PP', ); my $cipher_text = $cipher->encrypt( $input ); my $plain_text = $cipher->decrypt( $cipher_text ); }
Crypt::Rijndael::PP is a pure perl drop in alternative to Crypt::Rijndael, fully compatiable with Crypt::CBC. It exposes the exact same functionatly and can be used in place for any use case where you can not use the XS version of the Rijndael module.
Though named Crypt::Rinjdae::PP, this module implements the Advanced Encryption Standard (AES) and is suitable for all of your strong cryptographic needs. It will accept either a 128, 192, or 256 bit key and inputs that are multiples of the blocksize (which is 16 bytes). This module WILL NOT perform padding for you, if you need that functionatly consider using Crypt::CBC with the 'Rijndael::PP' cipher under the hood. The following encryption modes are available.
The default, but you most likely do not want to use this. In Electronic Code Book, each block is encrypted as a seperate indepedent block meaning that the same plain text produces the same cipher text.
My personal choice, uses an initialization vector (IV) as a 'salt' of sorts. Much better then ECB because the same plain text will not produce the same cipher text.
Similiar to CBC, but adds a counter to the IV for each succesive block.
Similiar to CBC, but uses the IV as input to the cipher algorthim then XOR'ing the plain text with the result of the algorthim.
Similiar to CFB, but uses the the result of the cipher algorthim before XOR'ing it with the plain text as input to the next block.
my $cipher = Crypt::Rijndael::PP->new( $key, Crypt::Rijndael::PP::MODE_ECB(), )
Generates an instance of Crypt::Rijndael::PP, accepts the key and the mode to use.
my $cipher_text = $cipher->encrypt( $input );
Encrypts the provided input, generating cipher text.
my $plain-text = $cipher->encrypt( $cipher_text );
Decrypts the provided input, gneerating plain text.
$cipher->set_iv( 'A' x 16 );
Sets the initialization vector.
my $iv = $cipher->get_iv();
Gets the current IV.
Crypt::Rijndael::PP is intended to be fully compatable with Crypt::Rijndael, and is fully compatable with Crypt::CBC when using 256 bit keys.
The repository for this module is publically available on github at https://github.com/drzigman/crypt-rijndael-pp so feel free to go fork yourself! Please use the github issues tracker for any normal bugs and try to create a failing test case if possible. Please email me (see below) for any sensitive issues you may come across.
If you aren't a member of your local Perl Mongers you really should be!
None of this would be possible without the excellent Rijndael algorithm written by Joan Daemen and Vincent Rijmen.
Special thanks to brian d foy for his faith and entrusting me with the Crypt::Rijndael module, the Houston Perl Mongers for allowing me to present to them my initial implementation, and to HostGator and BrainStorm Incubator for providing development resources.
Thanks to Leon Timmermans for pointing out a testing dependency on Crypt::Rijndal that was removed and for noting a perl 5.10 dependency that was not needed.
Robert Stone, <drzigman AT cpan DOT org>
<drzigman AT cpan DOT org>
Copyright 2015 Robert Stone This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU Lesser General Public License as published by the Free Software Foundation; or any compatible license.
See http://dev.perl.org/licenses/ for more information.
To install Crypt::Rijndael::PP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::Rijndael::PP
CPAN shell
perl -MCPAN -e shell install Crypt::Rijndael::PP
For more information on module installation, please visit the detailed CPAN module installation guide.