Live data from Hacker News

Creating and Verifying Hashes in PHP 5.5

jcurcio.com

41–44 of 44 posts

Re: Creating and Verifying Hashes in PHP 5.5

#41
post #8

Just noting if you're new to this you don't have to add a salt, by default password_hash with bcrypt will add a random one to each password.

How does that work? Don't you need the original salt to verify the hash?

The salt is stored in the hash itself, so it can extract the salt from any provided hash. (Neat huh?)

Re: Creating and Verifying Hashes in PHP 5.5

#42
post #31

Earlier quoted context omitted.

You can even do simpler. On signup store: $password = password_hash(md5($password),PASSWORD_BCRYPT); And on login: password_verify(md5($password), $password_hash); Then you just have apply password_hash() on all you passwords in database. Bonus the migration is instantaneous, you don't need a 6 month transition period. IMHO it do not reduce the security, but i'm not a crypto expert though.

It does add extra computational power to your log in though. While it is a minimal amount, depending on the size of your application it could be notable.

There is no way that it become notable. bcrypt is precisely designed to be slow and greedy in computational power.

So adding an extra md5 hashing is totally insignificant (in term of computation).

Re: Creating and Verifying Hashes in PHP 5.5

#43
This is an awesome improvement. I agree with BPatrianakos that hashing has not been easy enough for the average PHP dev - we hear that a lot.

As another option, you can also just not build any password infrastructure. We do all the hashing and authorization as a secure service and there are PHP devs of all levels using it... http://www.stormpath.com/docs/php/quickstart

Re: Creating and Verifying Hashes in PHP 5.5

#44
post #41

Earlier quoted context omitted.

How does that work? Don't you need the original salt to verify the hash?

The salt is stored in the hash itself, so it can extract the salt from any provided hash. (Neat huh?)

Here's a quick explanation of the format, in case anybody's interested:

http://pythonhosted.org/passlib/lib/passlib.hash.bcrypt.html...

Post reply on HN