Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 PHP Code: Simple reversible encryption Jump to:  
Category: >> PHP Code >> Simple reversible encryption Bookmark and Share

<< lastnext >>

Snippet Name: Simple reversible encryption

Description: This is an example of encryption and decryption that uses the Mcrypt library.

Also see:
» Saving Remote Images With PHP
» More File Type Detection in PHP
» Send iCal Email Meeting Requests using...
» Checking Server Status with PHP
» Call a PHP function when clicking on a...
» Send Unicode Response From PHP
» Reversible Encryption in PHP
» Use htpasswd file with PHPscripts
» PHP and Oracle: Connect to database
» Server Stats via PHP
» FTP via PHP
» Online PHP Tester
» Email attachments with PHP mail()
» Basic PHP Calendar
» Check syntax of multiple PHP files all...
» Create mySQL table with PHP
» Create thumbnails with PHP
» PHP to JavaScript Array
» Pass vars to/from PHP
» PHP - connect to an Oracle database
» PHP/Oracle 8 DB abstraction
» Oracle with PHP
» Oracle with PHP

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

$string = "Some text to be encrypted";
$secret_key = "This is my SeCrEt key";
// Encryption Algorithm
$etype = MCRYPT_RIJNDAEL_256;
// Create the initialization vector for added security.
$iv = mcrypt_create_iv(mcrypt_get_iv_size($etype, MCRYPT_MODE_ECB), MCRYPT_RAND);
// Output original string
PRINT "Original string: $string <p>";
// Encrypt $string
$encrypted_string = mcrypt_encrypt($etype, $secret_key, $string, MCRYPT_MODE_CBC, $iv);
// Convert to hexadecimal and send to browser
PRINT "Encrypted string: ".BIN2HEX($encrypted_string)."<p>";
$decrypted_string = mcrypt_decrypt($etype, $secret_key, $encrypted_string, MCRYPT_MODE_CBC, $iv);
PRINT "Decrypted string is: $decrypted_string";

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 26 users online    © 2009 psoug.org

Forgot your password?