Converting password hashes from bcrypt to argon2id #46367
Replies: 1 comment 5 replies
-
Yes, Laravel provides a simple way to upgrade bcrypt hashes to argon2id hashes. You can use the Hash::needsRehash() method to check if a given password hash needs to be rehashed with a different algorithm. To upgrade your existing bcrypt hashes to argon2id, you can modify the boot() method in your AuthServiceProvider class as follows:
This code registers a callback function that checks if a given password hash needs to be rehashed with argon2id. If the hash is a bcrypt hash and needs to be rehashed, the callback will return true, and Laravel will automatically rehash the password with argon2id the next time the user logs in. By using this feature, you can gradually upgrade your user's passwords to use a stronger hash algorithm without requiring them to reset their passwords. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone,
Does Laravel have a nice way to upgrade bcrypt hashes to argon2id? It would be nice to be able to upgrade hashes when users login.
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions