Thursday, 16 April 2009

Encrpt and Decrypt the Password in PHP


FUNCTION
ENCRYPT_DECRYPT1($Str_Message) {

$Len_Str_Message=STRLEN($Str_Message);
$Str_Encrypted_Message="";
echo
$Str_Encrypted_Message."
"
;
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;
}

No comments:

Post a comment