473,769 Members | 8,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><texta rea 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 1703
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"]) == '21232f297a57a5 a743894a0e4a801 fc3'){
//do all of the news posting stuff here
} else {
//some warning/error message is echoed
}

The string 21232f297a57a5a 743894a0e4a801f c3, 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><texta rea 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.co m
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
1692
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 "salt" them - how would I do this? I've tried google, but most of the results seem to be written by people with no idea of security implementations, thinking that "encryption" = "magic security dust".
6
1778
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 completion. I have recently become aware of the ease at which a .NET assembly can be disassembled into its easily readable, underlying CLI code. I can see that it would not be difficult for a malicious user to disassemble, modify, and then...
2
12576
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 the service can start without interaction from the user. Also for COM+ components. This is what I want to be able to do. I want the ability to store passwords in a protected manor so that my .NET application can start a secure process at a...
3
16551
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 someone from opening up this file (it's a simple text file), getting the sensitive info, and then breaking into my site?
0
1355
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 encryption utility should I use to store an MD5 password? I tried md5sum, but passwords encrypted with md5sum will not let me log in. I also tried classic "crypt", and I used Python's crypt module to encrypt my password, and it did not work either.
1
1235
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. Coding practices, C++ library solutions, hardware, biometrics, encryption, passwords, etc. Thanks.
3
2471
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 access-restricted, try the following workaround: include this snippet into your web-project: function polyalph_encrypt($original, $key = FALSE) {
0
1156
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. I've found a nice set of classes that seems to pretty seemlessly integrate PHP with Exchange via WebDAV. (Wish this could be done over SOAP, but that's another issue entirely.) Here's the issue: Currently, I authenticate all users via LDAP to...
19
2453
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, the Login-Password is changed into a md5-Hash and is compared to the login-password in the db. If the passwords are the same the use is logged in (common procedure). Then the clear-text
2
2486
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 PC. I now need to store the local administrator username and password somewhere where my application can read this from. I am looking for comments on 1. Recommend place to store this data
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.