Page 1 of 1

Encryption help

Posted: Wed Mar 29, 2006 11:10 pm
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

Posted: Wed Mar 29, 2006 11:16 pm
by s.dot
md5()
sha1()

for starters :P

Posted: Wed Mar 29, 2006 11:25 pm
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

Posted: Wed Mar 29, 2006 11:40 pm
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');   
}