473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Protecting Passwords -- Encryption needed?

I write a simple php script where I can post news to my website. There
is an html page (makenews.html) that has forms for username (in this
example it is 'admin'), password (in this example it is 'admin'),
subject line and message body. Once I fill out the information and
click submit, the html page sends the info to makenews.php. This
script starts out with:

<?php
if ($_POST["username"] == "admin" && $_POST["password"] == "admin"){
//do all of the news posting stuff here
}
else
//some warning/error message is echoed
?>

So my question: This php script is going to be containing my unique
username and password once I decide if it is safe or not. Is it? I
put it up for a minute and tried to download the actual php file but
every time I just got a file containing my error message echo. But I
still dont feel very safe having my password in plain text like that.
What should I do about this?

And if you guys don't mind I have another simple question that I dont
feel deserves its own topic. In relation to this...
I have the following code in makenews.html
Enter Body:<br><textarea name="body" cols=30 rows=10></textarea>
Which works fine except that any new lines that are entered in this
text area are omitted in $_POST["body"]. If I physically type a <p> or
<br> tag into the textarea it gets properly interpreted but I know
there has to be another way. For example as i'm typing right now, I
could hit enter a few times and it will be recorded and transferred
into my topic. What are the escape characters for a new line in a php
string and what can I do about this?

Thanks in advance for all the help -- you guys (and gals) are great
Cheers,
-Rob

Oct 11 '05 #1
3 1689
I forgot to mention that I have searched far and wide for solutions to
both problems. I'm asking you all as a last resort -- if you have any
links with further info please do share. I'm more than happy to learn
about it on my own but I simply couldn't find a possible solution. Any
password/encrytption stuff I searched for seemed to want to talk about
mySQL which I have no idea what is (some sort of database?) -- or if I
would even want to get involved in another huge task.

Cheers,
Rob

Oct 11 '05 #2
NC
Robizzle wrote:

I write a simple php script where I can post news to my website. There
is an html page (makenews.html) that has forms for username (in this
example it is 'admin'), password (in this example it is 'admin'),
subject line and message body. Once I fill out the information and
click submit, the html page sends the info to makenews.php. This
script starts out with:

<?php
if ($_POST["username"] == "admin" && $_POST["password"] == "admin"){
//do all of the news posting stuff here
}
else
//some warning/error message is echoed
?>

So my question: This php script is going to be containing my unique
username and password once I decide if it is safe or not. Is it?


There are really two independent questions here:

1. Can the user name and password hard-coded into a PHP script be
read by other users of your server (including administrators)?

The answser: ON A PROPERLY CONFIGURED SERVER, no. But you
cannot be sure of the proper configutation on a Web hosting
company's server. Hence, a simple recommendation:

if ($_POST["username"] == 'admin' and
md5($_POST["password"]) == '21232f297a57a5a743894a0e4a801fc3'){
//do all of the news posting stuff here
} else {
//some warning/error message is echoed
}

The string 21232f297a57a5a743894a0e4a801fc3, as you can guess,
is the MD5 hash of the word "admin". So even if the Web hosting
company'a administrators can take a peek at your files, all they
would see is a hash of the password, not the actual password.

2. Can the data I put into a form (including user name and password)
be intercepted in transit?

Theoretically, yes. How often it actually occurs is anyone's
guess. The protection here is to transmit data over secure
HTTP (https://), but that requires availability of SSL on the
server. In practice, this is often believed to be redundant
for simple content management applications; the cost of
security measures seems to exceed probable losses from absense
of security...

Cheers,
NC

Oct 11 '05 #3
Robizzle wrote:

<snip>
NC answered your first question well, so no reason for me to suggest the
same thing here.
And if you guys don't mind I have another simple question that I dont
feel deserves its own topic. In relation to this...
I have the following code in makenews.html
Enter Body:<br><textarea name="body" cols=30 rows=10></textarea>
Which works fine except that any new lines that are entered in this
text area are omitted in $_POST["body"]. If I physically type a <p> or
<br> tag into the textarea it gets properly interpreted but I know
there has to be another way. For example as i'm typing right now, I
could hit enter a few times and it will be recorded and transferred
into my topic. What are the escape characters for a new line in a php
string and what can I do about this?


For the text that is posted from the textarea, the newline characters
are submitted. Your problem is that you simply echo the result. The
thing to remember is that a textarea field acts just like plain text.
When it is rendered in the browser, the whitespace like new lines are
replaced with a single space. Try using nlbr($_POST['body']) which will
add <br /> tags with your newline characters for a (more) proper HTML
display.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Oct 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred Emmott | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi - just wondering how I should store passwords in a database - I was thinking MD5 hashes would be a good idea - but I've heard it's better to...
6
by: Nate A | last post by:
I am at the beginning stages of writing a massive database-connected business management application using the .NET framework and am becoming worried about the security of the application upon...
2
by: Peter Rilling | last post by:
How does Windows store passwords that it uses? For instance, when you install a service, you can provide it the username and password. This information is stored somehow so that at a later date...
3
by: John Buchmann | last post by:
In my web.config, I have a section that has a name and password: <credentials passwordFormat="Clear"> <user name="aaa" password="bbb" /> </credentials> Is this secure? What is to stop...
0
by: Milos Prudek | last post by:
I cannot set up password authentication with encrypted passwords. With plaintext passwords auth works fine. So my guess is that I am using an incorrect password encryption program. What...
1
by: Tom | last post by:
Scenario: Your life's work in the form of a compiled C/C++ dll program is stolen. What should have been done to make the hacking process almost impossible? I am interested in all solutions....
3
by: Jeremy Deuel | last post by:
Just an Idea: In PHP, passwords for different purposes often are stored plaintext in the source. I often wondered, how this could be prevented. So if you have a web-project, that is...
0
by: scoomey | last post by:
Hi folks- I've got an interesting problem. For our homebrewed PHP intranet application, I will soon be required to give users access to their email/calendar information from Microsoft Exchange....
19
by: Cord-Heinrich Pahlmann | last post by:
Hi, I have written a tool wich de/encrypts a few of my forum and bloggin-Passwords. My question is how secure it is. The following describes how I have encrypted my passwords. When I log in,...
2
by: Jeff Williams | last post by:
I am developing an application which will allow users (students) to run applications on PC's with elevated rights. This is necessary for some applications which require Administrator rights on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.