Encryption help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bonzol
Forum Newbie
Posts: 10
Joined: Mon Mar 20, 2006 8:44 pm

Encryption help

Post by Bonzol »

Hey there,

Just a quick question,

If I have a password hard coded into a .php file, so if anyone opens the file in a text editor or something they can see it, is there a way to encrypt it,, so it will appear in random charactors or something?

thanx in advanced
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

md5()
sha1()

for starters :P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Bonzol
Forum Newbie
Posts: 10
Joined: Mon Mar 20, 2006 8:44 pm

Post by Bonzol »

sorry for being a n00b, I don't really get it

if I have this

Code: Select all

if('bob' == $_POST['user_name'] and 'bob2' == $_POST['password']) 
{   
    header('Location: authenticated.php');  
}
how would I use that code to make bob2 encrypted
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

firstly, you'd have to store the password already hashed

so instead of

user: bob
password: mypassword12

you'd have
user: bob
password: somehashedvaluehearthatisn'treadable

then when you're doing your check you'd do something like this

Code: Select all

if(($_POST['username'] == 'bob') && (md5($_POST['password']) == 'bobspassword')))  
{    
    header('Location: authenticated.php');   
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply