-
-
Notifications
You must be signed in to change notification settings - Fork 417
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
refactor: add 'usedforsecurity=False' arg to hashlib.md5 usage #1190
Conversation
650c03f
to
a0b6bb4
Compare
I didn't realize we call md5 from 3 different places. Would you mind refactoring it into a single function, like |
Thanks! Also, mypy fails with
Can you check if there's a way to fix this? If not, adding an "ignore" comment is good enough for me. |
Latest commit adds an explicit check for Python 3.9+ to pass the Latest commit: if sys.version_info >= (3, 9):
return hashlib.md5(s.encode('utf8'), usedforsecurity=False).hexdigest()
else:
return hashlib.md5(s.encode('utf8')).hexdigest() Or slightly cleaner version with less repeated code hashlib.new("md5", s.encode("utf8"), usedforsecurity=False).hexdigest() # type: ignore |
Looks good to me. I'll wait a bit to see if @MegaIng has anything to add. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have anything to add. IMO a version check is cleaner than a type ignore.
@cquick01 Thank you for your contribution! |
Thank you all for working on this fix. When might the next release be cut? |
It's probably about time for a new release! I'll try to do it early next week. |
@jjtroberts Released 1.1.3 |
This argument was introduced in Python 3.9, but using
hashlib.new()
prevents <3.9 versions from throwing an exception.Tested running locally against 3.7, 3.9, and 3.10.
Closes #1187