Quote:
|
Originally Posted by mikesmith76
if you place your connection details outside of the document root there is no risk of the webserver accidentally serving those details to the public.
|
That was what I said, but
in addition I reccomendrd that you should use a cryptic folder name and a cryptic .ini file name.
Quote:
|
Originally Posted by mikesmith76
This is in no way the same as using an obscure directory name which in my eyes offers little or no security.
|
Agree to that, but as explained above I suggested more.
If you encrypt passwords, and you have to decrypt them somewhere, a hacker man guess the decryption algorithm. You may also use PHP's
md5 function to compare the encrypted version of a password with that entered by a user (technique used on most forums) which avoids the risks involved with encrypted values that could possibly be decrypted by a hacker.
Example:
cryptic.ini located in crypticfolder name
; Settings to connect to SQL
[Database_Settings]
host =
user =
password =
dbname =
; Default look of the site
[Preferences]
color =
size =
font =
ParseIniFile.php
<?php
$iniVars=parse_ini_file('../crypticfolder/cryptic.ini', TRUE)
$mysql=&new MySQL(
$iniVars['Database_Settings']['host'],
$iniVars['Database_Settings']['user'],
$iniVars['Database_Settings']['password'],
$iniVars['Database_Settings']['dbname']
);
...
...
?>
You need the MySQL class to connect to your database, where the constructor takes the password as one of its parameters that it gets from parse_ini_file. But this password is hidden in (and md5 hashed if you want) the cryptic.ini file. The cryptic.ini file may even be stored on a different server to make it even worse for hackers. Somebody even split the password and store the two halves on different servers.
Note: MD5 is not an encryption but a message digest algorithm.
Excersise 1:
Simplify and make the code
more secure without using security by obscurity.
Excersise 2: Simplifying or not, make the code more secure
without using SSL. You may use third party classes like PEAR.