Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
package Config::Confmanager; use Exporter; #export all the methods @EXPORT=qw(&Encrypt,&Decrypt); use warnings; use strict "refs"; use Crypt::CBC; #CPAN Module For Encryption And Decryption #Creating Constructor; sub new { my($self) = {}; bless ($self); return ($self); } #--------------------------------------------------------------------- +---------------------------------------- #Encrypt And Decrypt Method #--------------------------------------------------------------------- +--------------------------------------- sub CreateEncryptDecryptObject { $cipher = Crypt::CBC->new( {'key' => 'passport', 'cipher' => 'DES', 'iv' => '$KJh#(}q', 'regenerate_key' => 0, # default true 'padding' => 'space', 'prepend_iv' => 0 }); } #--------------------------------------------------------------------- +---------------------------------------- #Encrypt Method #Takes An Option Value As Plain String And Encrypts It #--------------------------------------------------------------------- +--------------------------------------- sub Encrypt { CreateEncryptDecryptObject(); my($encryptstring) = @_; my $cipherencryptstring = $cipher->encrypt($encryptstring); if (!$cipherencryptstring) { $log->error("Could not Encrypt requested string\n",); return ; } else { return($cipherencryptstring); } } #--------------------------------------------------------------------- +------------------------------------------- # End Of Encrypt Method #--------------------------------------------------------------------- +--------------------------------------------- #--------------------------------------------------------------------- +---------------------------------------- #Decrypt Method #Takes An Encrypted String And Decrypts It #--------------------------------------------------------------------- +--------------------------------------- sub Decrypt { CreateEncryptDecryptObject(); my($decryptstring) = @_; my $cipherdecryptstring = $cipher->decrypt($decryptstring); if (!$cipherdecryptstring) { $log->error("Could not Decrypt requested string\n",); exit; } else { return($cipherencryptstring); } } 1; #--------------------------------------------------------------------- +------------------------------------------- # End Of Decrypt Method #--------------------------------------------------------------------- +------------------------------------------- #--------------------------------------------------------------------- +------------------------------------------ =head1 NAME cut #--------------------------------------------------------------------- +------------------------------------------
janitored by ybiC: Balanced <readmore> tags around longish codeblock, to reduce vertical scrolling
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to call Module
by ambrus (Abbot) on Aug 24, 2004 at 16:16 UTC | |
by tilly (Archbishop) on Aug 24, 2004 at 16:20 UTC | |
by ambrus (Abbot) on Aug 24, 2004 at 16:38 UTC | |
by tilly (Archbishop) on Aug 24, 2004 at 22:09 UTC | |
|
Re: How to call Module
by Grygonos (Chaplain) on Aug 24, 2004 at 16:16 UTC | |
by Anonymous Monk on Aug 24, 2004 at 17:11 UTC | |
|
Re: How to call Module
by Zed_Lopez (Chaplain) on Aug 24, 2004 at 17:22 UTC | |
|
Re: How to call Module
by gaal (Parson) on Aug 24, 2004 at 16:58 UTC | |
by revdiablo (Prior) on Aug 24, 2004 at 17:14 UTC | |
by gaal (Parson) on Aug 24, 2004 at 18:47 UTC |