PAPI::Crypt - Symmetric and asymmetric encryption functions

SYNOPSIS

Symmetric encryption using AES algorithm

 use PAPI::Crypt;
 $str="This is a string to encrypt";
 $key="abdc34ff95048";
 $enc_str=PAPI::Crypt::encrypt_AES($str,$key,128);
 $dec_str=PAPI::Crypt::decrypt_AES($enc_str,$key,128);

Asymmetric signing using RSA algorithm

 use PAPI::Crypt;
 $str="This is a string to encrypt";
 $enc_str=PAPI::Crypt::encrypt_priv_RSA($str,"key.pem");
 $dec_str=PAPI::Crypt::decrypt_pub_RSA($enc,"pubkey.pem");

REQUIRES

Perl >= 5.6, Exporter, DynaLoader, openssl libraries >= 0.9.6

DESCRIPTION

PAPI::Crypt is a module containing a set of functions for:

- Encrypting and decrypting strings using the symmetric AES algorithm.

- Signing and verifying a string using the openssl implementation of the RSA algorithm.

METHODS

AES algorithm

$enc_str=PAPI::Crypt::encrypt_AES($str,$key,$size);
This function returns an encrypted version of the cleartext string $str, using the key defined by $key (in ASCII format), and the size of the key in the encryption process $size (whose possible values are 128, 192, or 256)
Arguments:
$str: String with the text to encrypt.
$key: Encryption key in ASCII format.
$size: Value that represents the size of the key in the encryption process. The acceptable values for this argument are: 128, 192, or 256
$enc_str=PAPI::Crypt::decrypt_AES($enc_str,$key,$size);
This function returns a cleartext version of the encrypted string $enc_str, using the key defined by $key (in ASCII format), and the size of the key in the decryption process $size (whose possible values are 128, 192, or 256).
Arguments:
$enc_str: String with the text to decrypt.
$key: Encryption in ASCII format.
$size: Value that represents the size of the key in the decryption process. The acceptable values for this argument are: 128, 192, or 256

RSA algorithm

$enc=PAPI::Crypt::encrypt_priv_RSA($str,$privkey_file);
This function returns an encrypted version of the string $str using the RSA algorithm. The private key used for encryption has to be stored into the file identified by $privkey_file, using the PEM format
Arguments:
$str: String with the clear text to be encrypted (signed)
$privkey_file: String with the name of the file containing the private key (in PEM format) that is going to be used by the signing process.
$dec_str=PAPI::Crypt::decrypt_pub_RSA($enc_str,$pubkey_file);
This function returns a decrypted version of the string $enc_str using the RSA algorithm. The public key used for this process has to be stored into the file identified by $pubkey_file, using the PEM format.
Arguments:
$enc_str: String with the cyphertext to be decrypted (verified).
$pubkey_file:String with the name of the file containing the private key (in PEM format) that is going to be used by the process.