ApacheCookieEncrypted
view release on metacpan or search on metacpan
Encrypted.pm view on Meta::CPAN
package Apache::Cookie::Encrypted;
#use Apache::Cookie;
use base qw(Apache::Cookie);
require Apache;
use strict;
use warnings;
use Crypt::CBC;
use Carp;
use vars qw($VERSION $key);
$VERSION = '0.03';
# get the encryption key
BEGIN {
my $r = Apache->request;
$key = $r->dir_config('COOKIE_KEY');
Encrypted.pm view on Meta::CPAN
return wantarray ? %enc_fetch_translated : \%enc_fetch_translated;
}
# data encryption subroutine
{
sub _encrypt_data {
my $data = shift;
croak("Can't encrypt anything without a key!") unless $key;
my $cipher = new Crypt::CBC($key,'Blowfish');
if (ref($data) eq "ARRAY") {
for (my $i = 0; $i <= $#$data; $i++) {
$data->[$i] = $cipher->encrypt_hex($data->[$i]);
}
return $data;
} else {
$data = $cipher->encrypt_hex( $data );
return $data;
}
}
}
# data decryption subroutine
{
sub _decrypt_data {
my $data = shift;
croak("Can't decrypt anything without a key!") unless $key;
my $cipher = new Crypt::CBC($key,'Blowfish');
if (ref($data) eq "ARRAY") {
for (my $i = 0; $i <= $#$data; $i++) {
$data->[$i] = $cipher->decrypt_hex($data->[$i]);
}
return $data;
} else {
$data = $cipher->decrypt_hex( $data );
return $data;
}
Encrypted.pm view on Meta::CPAN
I<Apache>(3), I<Apache::Cookie>(3), I<Apache::Request>(3)
=head1 AUTHOR
Jamie Krasnoo<jkrasnoo@socal.rr.com>
=head1 CREDITS
Apache::Cookie - docs and modules - Doug MacEachern
Crypt::CBC - Lincoln Stein, lstein@cshl.org
Crypt::Blowfish - Dave Paris <amused@pobox.com> and those mentioned in the module.
=cut
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Apache::Cookie::Encrypted',
'VERSION_FROM' => 'Encrypted.pm', # finds $VERSION
'PREREQ_PM' => { Crypt::CBC => 1.25, Crypt::Blowfish => 2.06, Apache::Cookie => 0.01 }, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'Encrypted.pm', # retrieve abstract from module
AUTHOR => 'Jamie Krasnoo <jkrasnoo@socal.rr.com>') : ()),
);
perl Makefile.PL
make
make install
DEPENDENCIES
This module requires these other modules and libraries:
Apache()
Apache::Cookie
Crypt::CBC
Crypt::Blowfish
Apache::Cookie is bundled with Apache::Request.
This module is meant to be used with mod_perl.
Suggested Modules
Crypt::Random
Math::Pari - needed by Crypt::Random
( run in 0.989 second using v1.01-cache-2.11-cpan-df04353d9ac )