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
In reply to How to call Module by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |