PHP encryption

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
jurerick
Forum Newbie
Posts: 2
Joined: Sat Nov 22, 2008 1:38 am

PHP encryption

Post by jurerick »

Hi! I'm a newbie in PHP

:banghead: how can i encrypt password using PHP? :arrow:
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: PHP encryption

Post by shiznatix »

mcrypt
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: PHP encryption

Post by alex.barylski »

EDIT | It might be worth noting that when you suggest encrypting a password, encrypting is not *exactly* what you are doing as "encryption" typically implies "decryption" using a public or private key. Passwords are usually "hashed" using a one-way function (md5, sha256, etc) and are generally not considered reversible or decryptable.

So while the results are certainly "cryptic" I would be careful adding the "en" to that term as most password hashes (in theory) are not supposed to be reversible.

END EDIT |

Alternatively you might consider using md5() -- although sha256 is better. :P
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: PHP encryption

Post by Eran »

Alternatively you might consider using md5() -- although sha256 is better.
Those are hashes, not encryption. You can't recover a hash back to its original state (at least in theory).
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: PHP encryption

Post by alex.barylski »

Those are hashes, not encryption. You can't recover a hash back to its original state (at least in theory).
I actually edited before you could correct me...either you missed it or you don't like reading anything I write :P
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP encryption

Post by JAB Creations »

Mordred had a very nice reply in an earlier thread I started.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: PHP encryption

Post by Eran »

I actually edited before you could correct me...either you missed it or you don't like reading anything I write
oops, missed it :P I guess we submitted simultaneously
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: PHP encryption

Post by alex.barylski »

Haha...it's all good...I was just teasing...

:drunk:
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: PHP encryption

Post by JAB Creations »

pytrin, good to see you finally added an avatar!

Now if PCSpectra would only honor us with some eye candy. :mrgreen:
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: PHP encryption

Post by Eran »

actually I had an avatar for a long time.. I just changed it recently
jrsl
Forum Newbie
Posts: 4
Joined: Wed Nov 26, 2008 7:35 pm

Re: PHP encryption

Post by jrsl »

Im certain mysql has a function to calculate a passwords md5 hash value and store that value instead of the text.

a way to do it would be to use this function then in you form have some JavaScript validation to confirm the passwords are a match before inserting the data for calculation.

when a user inputs there password to logon you will need to calculate its md5 hash value then confirm it with the database record if a match forward to page ect else password incorrect.

Cheers,
Justin
Post Reply