|
|
|
|
|
|
| |
|
<?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/>";
?> | |
|
|
| PHP Cookies - Simple cookie write/read methods that allow basic encryption Categories : PHP, Cookies, Security, Encryption | | | 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 | | | Scramble Eggs - php class to scramble/encode Categories : PHP, PHP Classes, 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 | | | 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 | | | Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | | | send_mail function to defeat Header Injection Hacking/Spamming Categories : PHP, Email, Form Processing, Security | | | Random Password Generator Categories : PHP, Strings, Security | | | Passgen: Automatically generate mixed case alpha numeric passwords Categories : PHP, Security | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | Generating and Matching Secure and Strong Password Hash Categories : PHP, PHP Classes, Cryptography, Security | | | IPTables Bandwidth statics Categories : PHP, Security, Network | | | Authenticator for Exchange Server LDAP Categories : PHP, Authentication, LDAP, Security, Sessions | | | Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags. Categories : PHP, PHP Classes, Algorithms, Security | | | Use of bitmasks to represent permissions Categories : PHP, Authentication, Bitwise Operators, Security, PHP Classes | |
| | | | 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 ?
| |
|
|