Results 1 to 6 of 6

Thread: How to Encrypt Database in PHP?

  1. #1
    Join Date
    May 2009

    How to Encrypt Database in PHP?

    Hi friends,
    I have completed the basic things of coding in PHP programming language. Now I have turned towards creating the database. I have somehow created it but I don't know anything about an encryption that takes place in PHP. So thought that you guys can help me on this topic. Please explain me how to Encrypt Database in PHP? Detailed information is very appreciable.

  2. #2
    Join Date
    Jul 2006

    Re: How to Encrypt Database in PHP?

    The SSL / SSH protects data traveling between server and client, but SSL / SSH does not protect data once in the database. SSL is a protocol in line. It is recommended to establish connections to the server with SSL to encrypt client / server exchanges, to improve security. You can also use an SSH client to encrypt the connection between client and server databases. If any of these protections is in place, it will be difficult to monitor your traffic and understand the information exchanged. Even if web-server and DBMS are on the same physical machine one can separate networks by setting database in virtual server inside the main system.
    "When they give you ruled paper, write the other way..." J.R.J.

  3. #3
    Join Date
    Jul 2006

    Re: Creating a Database in PHP?

    I would like to tell you some basic things about creating the database, since I think that you don't have much knowledge about it. After creating the Database, only the owner and the superuser can do anything with the tables of the database and requires that it gives rights to all stakeholders who will work on this basis. Applications should never connect to the server database under the name of the owner or administrator, as these users have very important rights, and can run any application. You can create different user databases for each aspect of your application with very limited rights to planned actions. It must then ensure that the same user has the rights to several use cases.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  4. #4
    Join Date
    Jul 2006

    Re: How to Encrypt Database in PHP?

    Encrypting data is a good solution to reduce this threat, but very few databases offer this type of encryption. The easiest way to circumvent this problem is to create your own encryption software, and use in your PHP scripts. PHP can assist you in this task thanks to the many extensions available to it as Mcrypt and Mhash, who know a wide range of encryption methods. The PHP script will encrypt the data to be stored and read when they are replayed.
    Signatures reduce available bandwidth

  5. #5
    Join Date
    Apr 2008

    Re: How to Encrypt Database in PHP?

    In the case of very sensitive data if the original representation is not necessary using a hash is a good solution. The classic example is the storage of passwords in the database, after having passed the MD5. The following is an example that explains the same :
    PHP Code:

    sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
    pg_escape_string($username), md5($password));
    $result pg_query($connection$query);

    $query sprintf("SELECT 1 FROM users WHERE name='%s' AND pwd='%s';",
    pg_escape_string($username), md5($password));
    $result pg_query($connection$query);
    if (
    pg_num_rows($result) > 0) {
    'Welcome, $username!';
    } else {
    'Authentication failed for $username.';

  6. #6
    Join Date
    May 2008

    Re: How to Encrypt Database in PHP?

    You can claim that the attacker must first obtain information on the scheme of the database, in most cases injections. True, but you never know how or when this information has filtered, and If this happens, your database will be in great danger. If you are using an open source, or a base that is public domain, or a pattern that belongs to a content management or forum, the hacker can easily obtain a copy of the code that you use. This may be a risk if it is a poorly conceived.

Similar Threads

  1. How to Encrypt /boot
    By dogaman in forum Operating Systems
    Replies: 4
    Last Post: 13-01-2011, 04:32 AM
  2. How to Encrypt Oracle Database File
    By GracieSingh in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 03:45 AM
  3. How to Encrypt PHP Code ?
    By Abbudin in forum Software Development
    Replies: 4
    Last Post: 22-04-2009, 05:01 AM
  4. Encrypt your personal SMS
    By FaMe FacToR in forum Portable Devices
    Replies: 3
    Last Post: 07-04-2009, 12:41 AM
  5. How to encrypt Emails?
    By Navman in forum Tips & Tweaks
    Replies: 0
    Last Post: 10-11-2008, 02:45 PM

Posting Permissions

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