Page 1 of 1

PHP encryption

Posted: Wed Nov 26, 2008 4:09 am
by jurerick
Hi! I'm a newbie in PHP

:banghead: how can i encrypt password using PHP? :arrow:

Re: PHP encryption

Posted: Wed Nov 26, 2008 6:55 am
by shiznatix
mcrypt

Re: PHP encryption

Posted: Wed Nov 26, 2008 8:20 am
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

Re: PHP encryption

Posted: Wed Nov 26, 2008 8:23 am
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).

Re: PHP encryption

Posted: Wed Nov 26, 2008 9:57 am
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

Re: PHP encryption

Posted: Wed Nov 26, 2008 4:25 pm
by JAB Creations
Mordred had a very nice reply in an earlier thread I started.

Re: PHP encryption

Posted: Wed Nov 26, 2008 6:04 pm
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

Re: PHP encryption

Posted: Wed Nov 26, 2008 6:39 pm
by alex.barylski
Haha...it's all good...I was just teasing...

:drunk:

Re: PHP encryption

Posted: Wed Nov 26, 2008 6:54 pm
by JAB Creations
pytrin, good to see you finally added an avatar!

Now if PCSpectra would only honor us with some eye candy. :mrgreen:

Re: PHP encryption

Posted: Wed Nov 26, 2008 6:55 pm
by Eran
actually I had an avatar for a long time.. I just changed it recently

Re: PHP encryption

Posted: Wed Nov 26, 2008 9:27 pm
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