That's what the cost
parameter is for. More cost equals more hashing which takes you longer to calculate but also the potential cracker who wants to crack the password by brute-force.
So it is somewhat expected and wanted that password_hash takes longer than just a nanosecond, you have to play around with the cost
a bit to see what works for you the best, but again, it shouldn't be too fast!
If I remember correctly, bcrypt
is at the moment the default hasing-algorithm and the cost isn't linear for bcrypt
. You'd see a exponential time-increase for a cost
increase.