Encrypt/Secure DB connection string in php

前端 未结 3 1857
日久生厌
日久生厌 2021-01-07 10:10

one of the project required me to encrypt DB connection string (username & password).

Usually I use .htaccess to restrict user to access from web. But this pro

3条回答
  •  天命终不由人
    2021-01-07 10:36

    It's impossible.

    If you encrypt the MySQL password for example with mcrypt, only way to decrypt that MySQL password is to use your secret mcrypt password, which will be, obviously, stored also in some PHP script or elsewhere on the server.

    Whoever has an access to the server or can read the script will get an access to MySQL password or any other password used to decrypt MySQL password.

    If you project requires you to store password not in clear text, ask the project manager about this logical problem - how can I decrypt the password and how can I store a password to decrypt the password.

提交回复
热议问题