Jump to content

Archived

This topic is now archived and is closed to further replies.

Chetan

Please help me...

Recommended Posts

Dont tell me this is in the wrong forum or something, my brain is getting angry at PHP and GD. (move it if you want to)
1. How do you encrypt strings and being allowed to decrypt them?
2. The latest version of GD available on windows does not support PHP, how can i get an older one? (i might be able to get older ones but yet help me if you can)

I really need help.
and for the first one dun give me MD5 or SHA1 cause they cant be decrypted

Share this post


Link to post
Share on other sites
gd is built into php enable it in php.ini

and lookup hash ok

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=101912.msg403779#msg403779 date=1153914620]
gd is built into php enable it in php.ini

and lookup hash ok
[/quote]
Yep, GD has been packaged with PHP since version 4.3. Although I believe all hashing algorythms are one way.

For what reason do you want to be able to encrypt/decrypt strings? I don't think there are any encrypt/decrypt functions built into PHP as standard...

Share this post


Link to post
Share on other sites
<?PHP
/*
Description : A function with a very simple but powerful xor method to encrypt
              and/or decrypt a string with an unknown key. Implicitly the key is
              defined by the string itself in a character by character way.
              There are 4 items to compose the unknown key for the character
              in the algorithm
              1.- The ascii code of every character of the string itself
              2.- The position in the string of the character to encrypt
              3.- The length of the string that include the character
              4.- Any special formula added by the programmer to the algorithm
                  to calculate the key to use
*/
FUNCTION ENCRYPT_DECRYPT($Str_Message) {
//Function : encrypt/decrypt a string message v.1.0  without a known key
//Author  : Aitor Solozabal Merino (spain)
//Email    : aitor-3@euskalnet.net
//Date    : 01-04-2005
    $Len_Str_Message=STRLEN($Str_Message);
    $Str_Encrypted_Message="";
    FOR ($Position = 0;$Position<$Len_Str_Message;$Position++){
        // long code of the function to explain the algoritm
        //this function can be tailored by the programmer modifyng the formula
        //to calculate the key to use for every character in the string.
        $Key_To_Use = (($Len_Str_Message+$Position)+1); // (+5 or *3 or ^2)
        //after that we need a module division because canĀ“t be greater than 255
        $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;  //xor operation
        $Encrypted_Byte = CHR($Xored_Byte);
        $Str_Encrypted_Message .= $Encrypted_Byte;
       
        //short code of  the function once explained
        //$str_encrypted_message .= chr((ord(substr($str_message, $position, 1))) ^ ((255+(($len_str_message+$position)+1)) % 255));
    }
    RETURN $Str_Encrypted_Message;
} //end function
?>



sample use of the function
$Str_Test="This function is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation in any version
of the License."."<br>"."This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."."<br>"."Hello Aitor, Wellcome Home"."<br>";
ECHO $Str_Test."<br>";
$Str_Test2 = ENCRYPT_DECRYPT($Str_Test);
ECHO $Str_Test2."<br><br>";
$Str_Test3 = ENCRYPT_DECRYPT($Str_Test2);
ECHO "<br>".$Str_Test3."<br>";
?>

Share this post


Link to post
Share on other sites
You encrypt/decrypt strings with basic encryption such as base64_encode/decode

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.