0

Here is my question, i am trying to hide address value in URL

URL is something like this

example.com/linkdl/preview/index.php?address='http://mysiteexample.com'

I am trying to hide, ?address='http://mysiteexample.com' part, but i am not sure, what is best way

i have an idea to use base64_encode($adresa), but i am not sure will i have problems with (encoding/decoding special) characters in URL

$click = 'OtvoriProzor("'.$file_path.'&pk='.$sesija->pk.'&adresa='.base64_encode($adresa).
                    '&IDIstorijaElement='.$element->GetId().'", "Prevod", 700, 500);';

This is very insecure, can add some function for encryption, to encrypt and decrypt parametar, or will md5 help me here. Also should i use function url_decode url_decode instead?

6
  • possible duplicate of Decode base64 string - php Commented Feb 4, 2015 at 8:20
  • use POST instead of GET... and when you want to secure your data, use https instead of http Commented Feb 4, 2015 at 8:20
  • 1
    Please specify for what purpose you want to "hide" that value. Aesthetic reasons? "Security"? Secrecy? What exactly do you need to protect then from whom? Commented Feb 4, 2015 at 8:20
  • Secrecy i want to prevent direct download, its address for direct download, its impossible to use post because system is based on GET Commented Feb 4, 2015 at 8:23
  • Provide more details. Download from where? Where would one get such a link from? How would encrypting that value fundamentally provide an improvement. Commented Feb 4, 2015 at 8:26

1 Answer 1

5

Since md5 is a hash algorithm, you won't be able to get back what you encoded. You can use base64 and urlencode to avoid problems with some characters:

<?php
$url = urlencode(base64_encode($adresa));
?>

And you will decode it with:

<?php
$addr = base64_decode(urldecode($_GET['adresa']));
?>
Sign up to request clarification or add additional context in comments.

4 Comments

can i use crypt functions
1) Your decoding needs to be reversed, 2) this is merely light obfuscation, nothing is hidden here.
You won't get the clean url in the GET parameter, I don't have to reverse anything
If you first base 64 encode, then url encode, you need to reverse this by first url decoding, then base 64 decoding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.