WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security Click here to Update Your Picture
Anand kumar
Date : Feb 12th 2008
Grade : 2 of 5 (graded 6 times)
Viewed : 14994
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Anand kumar
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
//Function : encrypt/decrypt a string message
//Author   : Anand sharma

FUNCTION ENCRYPT_DECRYPT($Str_Message) {
   
$Len_Str_Message=STRLEN($Str_Message);
   
$Str_Encrypted_Message="";
    echo
$Str_Encrypted_Message."<br/>";
    FOR (
$Position = 0;$Position<$Len_Str_Message;$Position++){
       
       
$Key_To_Use = (($Len_Str_Message+$Position)+1);
       
$Key_To_Use = (255+$Key_To_Use) % 255;
       
$Byte_To_Be_Encrypted = SUBSTR($Str_Message, $Position, 1);
       
$Ascii_Num_Byte_To_Encrypt = ORD($Byte_To_Be_Encrypted);
       
$Xored_Byte = $Ascii_Num_Byte_To_Encrypt ^ $Key_To_Use
       
$Encrypted_Byte = CHR($Xored_Byte);
       
$Str_Encrypted_Message .= $Encrypted_Byte;
    }
    RETURN
$Str_Encrypted_Message;
}


FUNCTION
ENCRYPT_DECRYPT1($Str_Message) {

   
$Len_Str_Message=STRLEN($Str_Message);
   
$Str_Encrypted_Message="";
    echo
$Str_Encrypted_Message."<br/>";
    FOR (
$Position = 0;$Position<$Len_Str_Message;$Position++){
       
       
$Key_To_Use = (($Len_Str_Message+$Position)+1);
       
$Key_To_Use = (255+$Key_To_Use) % 255;
       
$Byte_To_Be_Encrypted = SUBSTR($Str_Message, $Position, 1);
       
$Ascii_Num_Byte_To_Encrypt = ORD($Byte_To_Be_Encrypted);
       
$Xored_Byte = $Ascii_Num_Byte_To_Encrypt ^ $Key_To_Use
       
$Encrypted_Byte = CHR($Xored_Byte);
       
$Str_Encrypted_Message .= $Encrypted_Byte;
       
       
    }
    RETURN
$Str_Encrypted_Message;
}
?>


Example Usage
<?php
echo "Encryption of a string '100abc' is :";
echo
ENCRYPT_DECRYPT("100abc")."<br/>";
echo
"Decryption of a string '100abc' is :";
$a= ENCRYPT_DECRYPT("100abc")."<br/>";
echo
ENCRYPT_DECRYPT1($a)."<br/><br/>";
?>




A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
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
Function to generate readable/remeberable random password
Categories : PHP, Security, Security
Scramble Eggs - php class to scramble/encode
Categories : PHP, PHP Classes, Security, Encryption
ENCRYPT_DECRYPT_64 - A new version of ENCRYPT_DECRYPT without a known key with 2 added functions ENCODE and DECODE to ASCII characters between 32 and 127 codes.
Categories : PHP, Encryption, Security
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
A login page that require username, password and userlevel.
Categories : PHP, Security, Sessions, MySQL, Databases
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
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
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
Password using php, Javascript, and html form
Categories : Security, PHP, Authentication, Java Script
Use of bitmasks to represent permissions
Categories : PHP, Authentication, Bitwise Operators, Security, PHP Classes
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
Easily Grant Temporary SSH Access to yourself when in remote location
Categories : PHP, Linux, Cron, Security
 aitor solozabal wrote :1755
This is the same code from:

PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character.

But is not mentioned. Why ?