Forum Moderators: coopster
Creating username/password class...
<?php
class vars {
private function set($name,$value) {$this->$name = $value;}
private function give_me($name){return $this->$name;}
}if (//arguement) {$thepassword = "my_password";}
$vars = new vars();
$vars->set('password',$thepassword);
?>
Class Username/Password usage...
$username = $vars->give_me('username');
$password = $vars->give_me('password');
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password) or exit();
In the class file if I use my password it would be stored in plain text right now since I wouldn't know how to encrypt or use a hash if that is at all possible?
- John
The whole reason behind this question is that a web friend showed me some vulnerability on his server where he could see all the serverside code for other clients on a shared server though thankfully it does not work on my live server.
- John
Regarding open text passwords versus encrypted ... think about it this way ... if you have developed code or an application that requires you to connect to a database you are going to need to establish a connection. That connection is going to use a value that you pass to it. If you have that value in your class as either plain text or an "encrypted" password, it is still available to anybody that has access to view your class, as is the case on your friend's server. Example ...
class myClass
{
var $myPassword = 'plaintext';
// or the "encrypted" version:
var $myPassword = 'B0A1EEF0C2C3GGF1D4B0A1EEF0C2C3GG';
}
$dbh = mysql_connect($hostname, $username, $password) or exit();
Like it has been said if they can get that class they can get the decrypt method as well. Anyway you look at it if someone gets at your back end code/DB you have issues and encrypted passwords won't matter cause they are already in.
How to do this is greatly dependent on what OS/DB/PHP/Apache versions you are using.
There are lots of help guides out there if you do a search. If you have someone hosting for you tell them you want to have the server audited. It might cast a couple bucks but it would be a good thing.
If you are hosting you might want to look at getting a third party security company to audit your server for you. They will give you a list of suggestions for tightening things up. You can even get your code audited which isn't a bad thing.