redcoder
redcoder

Reputation: 107

php encrypt and decrypt

can anyone tell me how to encrypt and decrypt a URL string ?

I want to encrypt a hyperlink ...

Upvotes: 0

Views: 2150

Answers (3)

Maulik patel
Maulik patel

Reputation: 2440

    $confirmpassword = $_POST['confirmpassword'];
            $value_check = true;
            $ciphering = "AES-128-CTR";
            $options = 0; 
            $encryption_iv = '1234567891011121'; 
            $encryption_key = "GeeksforGeeks";
            $confirmpasswordencryption = openssl_encrypt($confirmpassword, $ciphering,$encryption_key, $options, $encryption_iv);  

$encryption = "pABqPJhobIMHzqai"
                                                        $ciphering = "AES-128-CTR";
                                                        $options = 0;
                                                        $decryption_iv = '1234567891011121'; 
  
// Store the decryption key 
$decryption_key = "GeeksforGeeks"; 
  
// Use openssl_decrypt() function to decrypt the data 
$decryption=openssl_decrypt ($encryption, $ciphering,  
        $decryption_key, $options, $decryption_iv); 
  
// Display the decrypted string 
echo "Decrypted String: " . $decryption; 

Upvotes: 0

vsr
vsr

Reputation: 3198

If you can use database,you could create a table to map a file to an id.

Create a 'mapping_table'

id - integer
file_location - string

Your URL would look something like localhost/waterwell/e_book.php?id=12 .

Upvotes: 1

Scott Evernden
Scott Evernden

Reputation: 39986

make links that return to your server with querystring GET params identifying the file. the server can then do echo file_get_contents() after you figure out which file from the inputs

In your example it's trivial. simply omit the portion of the url you don't want shown and fill it back in on the server.

Upvotes: 0

Related Questions