|
|
|
|
|
|
| |
This Class uses three algorithms for encryption
BLOWFISH
SAFERPLUS
SERPENT
Check out whether ur mcrypt module supports these algorithms
Please use rand or srand to select the type of the algo and store the IV ,Key and rand in the database
for more design changes or suggestions mail me @ veevakan@email.com
| <?php
class encrypt
{
function enc_str($cipher,$key,$string)
{
if ($cipher==1)
{
$iv=mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_BLOWFISH,MCRYPT_MODE_ECB),MCRYPT_RAND);
$cryptext=mcrypt_encrypt (MCRYPT_RIJNDAEL_256,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else if ($cipher==2)
{
$iv=mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_SAFERPLUS,MCRYPT_MODE_ECB),MCRYPT_RAND);
$cryptext=mcrypt_encrypt (MCRYPT_SAFERPLUS,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else if ($cipher=3)
{
$iv=mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_SERPENT,MCRYPT_MODE_ECB),MCRYPT_RAND);
$cryptext=mcrypt_encrypt (MCRYPT_SERPENT,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else
{
$iv=mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_XTEA,MCRYPT_MODE_ECB),MCRYPT_RAND);
$cryptext=mcrypt_encrypt (MCRYPT_XTEA,$key, $string, MCRYPT_MODE_ECB, $iv);
}
return $cryptext;
}
function dec_str($cipher,$key,$string,$iv)
{
if ($cipher==1)
{
$dec_text=mcrypt_decrypt (MCRYPT_RIJNDAEL_256,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else if ($cipher==2)
{
$dec_text=mcrypt_decrypt (MCRYPT_SAFERPLUS,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else if ($cipher==3)
{
$dec_text=mcrypt_encrypt (MCRYPT_SERPENT,$key, $string, MCRYPT_MODE_ECB, $iv);
}
else
{
$dec_text=mcrypt_encrypt (MCRYPT_XTEA,$key, $string, MCRYPT_MODE_ECB, $iv);
}
return $dec_text;
}
}
?> | | |
|
| very simple ftp class Categories : PHP, PHP Classes, FTP | | | PHP Paypal IPN Integration Class v1.0.0 Categories : PHP, PHP Classes, Payment Gateways | | | A Timing Class Categories : PHP, PHP Classes, Date Time | | | The class to check load time of your script
VERY usefull for relatively slow applications, but not only.. Categories : PHP, PHP Classes, Debugging | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | usercounter class Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables | | | RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | These PHP Classes Check if a host is alive using various methods. Categories : PHP, PHP Classes, Sockets, CURL | | | an example of the cyberlib payment class Categories : PHP, PHP Classes, Ecommerce, Credit Cards | | | Power Form Validation Categories : PHP, PHP Classes, Data Validation | | | MySQL Handler Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | Browser Detecor Class Categories : PHP Classes, PHP, HTML | |
|
|
|