在php中加密/安全数据库连接字符串 [英] Encrypt/Secure DB connection string in php

查看:361
本文介绍了在php中加密/安全数据库连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中一个项目要求我加密DB连接字符串(username& password)。

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

通常我使用.htaccess限制用户从网络访问。
但是这个项目要我存储userid&

Usually I use .htaccess to restrict user to access from web. But this project want me to store userid & password not in clear text.

如果没有明确的文字,密码不能清除。

解决方案

推荐答案

你加密MySQL密码,例如用mcrypt,只有方式来解密,MySQL密码是使用你的秘密mcrypt密码,这将是,显然,存储在一些PHP脚本或服务器上的其他地方。

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.

谁可以访问服务器或可以读取脚本将获得访问MySQL密码或任何其他用于解密MySQL密码的密码。

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.

这篇关于在php中加密/安全数据库连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆