|
|
|
|
|
|
|
|
|
Like this code?
Show the author your appreciation.
|
| |
These functions allow you to easily encrypt and decrypt text using the mcrypt PHP extension (required) and the Blowfish encryption algorithm.
| <?php
function Encrypt_Helper($string, $key)
{
if (extension_loaded('mcrypt') === true)
{
return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, substr($key, 0, mcrypt_get_key_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB)), trim($string), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
return false;
}
function Decrypt_Helper($string, $key)
{
if (extension_loaded('mcrypt') === true)
{
return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, substr($key, 0, mcrypt_get_key_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB)), base64_decode($string), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
return false;
}
?> | |
Usage example
| <?php
// returns "K9e+8tesCIziQfNH1QFAsQ=="
echo Encrypt_Helper('top secret info', 'this is the password');
// returns "top secret info"
echo Decrypt_Helper('K9e+8tesCIziQfNH1QFAsQ==', 'this is the password');
?> | | |
|
| A PHP function to encrypt and decrypt a number or string or a combination of the two. Categories : PHP, Encryption, Security | | | Encrypt/Decrypt string with a given key by using mcrypt module of PHP (suitable to store encrypted data into any type of databases). Categories : PHP, Encryption | | | PHP Cookies - Simple cookie write/read methods that allow basic encryption Categories : PHP, Cookies, Security, Encryption | | | PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character. Categories : PHP, Algorithms, Security, Authentication, Encryption | | | base64 with encryption - encode and decode sessions Categories : PHP, PHP Classes, Encryption, Sessions | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Scramble Eggs - php class to scramble/encode Categories : PHP, PHP Classes, Security, Encryption | | | MD5 based block cypher in 128 bit CFB Categories : PHP, Encryption, MD5 | | | Upload any fixed type of files, control file type through javascript and encrypt filename using php so file not get overwrite Categories : PHP, Java Script, Functions, PHP References, Form Processing | | | How to connect to MS SQL 6.x+ database server via ODBC functions of
PHP3 compiled with iODBC and Openlink drivers under Linux. Categories : Databases, MS SQL Server, PHP, ODBC | | | function_exists -- Return true if the given function has been defined Categories : PHP, PHP Functions, Functions | | | Is there any way to test that the $result has null values or not without reading the field values in the results in postgre?
Categories : PostgreSQL, PHP, Databases | | | How to get the exit code of a function ran by system(). Categories : PHP | | | IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival. Categories : PHP, Algorithms, Security, URLs | | | GroupIT Engine v1.00rc1
Categories : PHP, Content Management, MySQL, Databases | |
| |
| |
|