Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved PBKDF2 defaults #753

Closed
wants to merge 3 commits into from
Closed

Improved PBKDF2 defaults #753

wants to merge 3 commits into from

Conversation

robik
Copy link
Contributor

@robik robik commented Aug 4, 2015

Changes:

  • Increased number of rounds from 1000 to 50000
  • Changed default hash from SHA1 to SHA256
  • Also updated documentation to not suggest SHA1 with 2000 rounds.

Rationale:
Suggested number of PBKDF2-SHA256 varies, but can reach up to 200,000. However, for performance reasons 50,000 is a good start and should give a bit more protection.

Local performance test [50 times]:

>>> timeit("generate_password_hash('testpassword', 'pbkdf2:sha1:1000')", "from werkzeug.security import generate_password_hash", number=50)
0.6354742040002748
>>> timeit("generate_password_hash('testpassword', 'pbkdf2:sha256:50000')", "from werkzeug.security import generate_password_hash", number=50)
36.46516097099993

References:
https://docs.python.org/2/library/hashlib.html#hashlib.pbkdf2_hmac
http://security.stackexchange.com/questions/3959/recommended-of-iterations-when-using-pkbdf2-sha256

- Increased number of rounds from 1000 to 50000
- Changed default hash from `SHA1` to `SHA256`
- Also updated documentation to not suggest SHA1 with 2000 rounds.
@untitaker
Copy link
Contributor

Excellent, thanks!

@untitaker untitaker closed this in 4baf7f2 Jun 3, 2016
@untitaker untitaker removed the ready label Jun 3, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants