-
Notifications
You must be signed in to change notification settings - Fork 0
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
added module for unix compatibility #1
base: main
Are you sure you want to change the base?
Conversation
from hashlib import sha1 | ||
from base64 import b64encode | ||
password = fn.get_password_bytes(password) | ||
hashed = sha1(password).digest() |
Check failure
Code scanning / CodeQL
Use of a broken or weak cryptographic hashing algorithm on sensitive data High
Sensitive data (password)
Sensitive data (password)
Sensitive data (password)
Sensitive data (password)
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 months ago
To fix the problem, we should replace the use of the SHA-1 hashing algorithm with a stronger, more secure algorithm suitable for password hashing. One of the best options is to use the argon2
algorithm, which is designed to be computationally expensive and includes a per-password salt by default.
Steps to fix:
- Import the
PasswordHasher
class from theargon2
library. - Replace the SHA-1 hashing logic with the
argon2
hashing logic. - Ensure that the new function maintains the same interface and functionality as the original.
-
Copy modified line R23 -
Copy modified lines R25-R27
@@ -22,6 +22,6 @@ | ||
def encrypt_sha1(password: t.AnyStr) -> str: | ||
from hashlib import sha1 | ||
from base64 import b64encode | ||
from argon2 import PasswordHasher | ||
password = fn.get_password_bytes(password) | ||
hashed = sha1(password).digest() | ||
return "{SHA1}" + b64encode(hashed).decode() | ||
ph = PasswordHasher() | ||
hashed = ph.hash(password) | ||
return hashed |
-
Copy modified line R9
@@ -8,2 +8,3 @@ | ||
|
||
argon2-cffi = "^23.1.0" | ||
[dev-packages] |
Package | Version | Security advisories |
argon2-cffi (pypi) | 23.1.0 | None |
No description provided.