Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Usually at home

    Unanswered: Encrypting PHP Code


    Am interested in finding out which of the Encryption Systems available (Open Source or not) people think are the best for encrypting source code.

    By day, mild mannered number cruncher.
    By night, caped crime fighter.

  2. #2
    Join Date
    Jul 2008
    Encrypt and encode PHP scripts easily and quickly. Use it for encrypting your scripts for distribution, or protecting sensitive information such as MySQL username/password.

    Encoded scripts work with PHP Linux/Unix and Windows servers. Encoder runs on Windows systems.

  3. #3
    Join Date
    May 2008

    No reason to encrypt PHP

    There is no reason to encrypt PHP.

    If you want to encrypt a field within PHP,(for example, a password), you can easily do that with 2 lines of code; and I'll show those below.

    Why not encrypt PHP?
    PHP, or Pre-HyperText-Processor, is a server-side scripting language. This means that all of the code within PHP is read by the server, parsed, than sent to the user's browser as HTML.

    In other words, only your server can see your PHP code, no user can hack in and see that data without having your FTP information.

    Now I was working on an open source project the other day that required me to give away some FTP information. I had some code in a page that I wanted encrypted. I tried using Notepad++'s encrypt function to scramble the connection info. I tried it, and it didn't work because PHP was not built for encryption. It just gave me a list of errors when I loaded the page.

    After finding that out, I just made a new page for the sensitive data that wasn't in the open source FTP directory that I gave out. It was still on my server, so it worked with everything still, yet nobody except me could see/edit this file.

    As for encrypting something like a username or a password inside PHP, there's a couple built in functions that support this. I'll show you how to encrypt a password with the crypt function:

    Encrypting a single Field:
    PHP Code:
    $password crypt($_POST['password'],$salt); 
    You need to use this code when creating/updating accounts and logging in accounts.

    creating/updating mySQL query:
    PHP Code:
    $password crypt($_POST['password'],$salt);

    $update) {

    mysql_query('UPDATE `users` 
      SET `blah` = "blah" 
      WHERE `password` = "'
      AND `username` = '
      LIMIT 1'
    ) or die('Could not connect');
    $create) {

    mysql_query('INSERT INTO `users` 
      LIMIT 1'
    ) or die('Could not connect');

    Logging in Users
    PHP Code:
    $password crypt($_POST['password'],$salt);

    $_POST['submit'])) {

    $select='SELECT * FROM `users` 
      WHERE `username` = "'
      AND `password` = "'
      LIMIT 1'
    $query=mysql_query($select) or die('Problem while logging in.');
    'Username: '.$row['username'].'<br>';
    'Encrypted Password: '.$row['password'].'<br>';
    'blah: '.$row['blah'].'<br>';

    Hope that helped
    Keeping it real by Testing pre-post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts