PHP encryption

Discussion in 'PHP' started by tanyania, Jun 28, 2011.

  1. #1
    basically, i'd like to know how to encrypt a URL, for inclusion at the bottom of every page in a script.

    That way, it's just that much harder for the non-programmers out there to remove it.


    I don't expect you to do it for me, but maybe a quick run-down would be nice. (yeah: I could google it, but we wouldn't really have a forum now, would we? lol)
     
    tanyania, Jun 28, 2011 IP
  2. The Webby

    The Webby Peon

    Messages:
    1,852
    Likes Received:
    30
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You can use eval function with base64 encode and decode.
    Like get the encoded script bit:
    $encodedURL = base64_encode("echo '<a href=\"http://www.example.com\">Example Site</a>'"); // $encodedURL will contain an encoded string, simply print it to get the string
    PHP:
    And then include this code in your script

    eval(base64_decode($encodedURL)); // Replace $encodedURL with the encoded String
    PHP:
    But anyone can just remove the whole eval function to remove your link.


    Another way is to use PHP mcrypt lib to write a full blown symmetric encryption function. the decrypts the encrypted string and inserts the URL in the page.. But then anyone can simply remove the call to the function.

    Its only fruitful if you encrypt the whole page, then it will be hard for most people to alter your script.
     
    Last edited: Jun 28, 2011
    The Webby, Jun 28, 2011 IP