Created
August 20, 2020 08:30
-
-
Save 0ex-d/8222b0edb2c1b5b2fbaba6114d510902 to your computer and use it in GitHub Desktop.
Reduce "crackability" https://blog.tecladocode.com/learn-python-encrypting-passwords-python-flask-and-passlib/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Use 'passlib' for password encryption and make the perfect round algo. ;) | |
Required: pip install passlib | |
''' | |
from passlib.context import CryptContext | |
pwd_context = CryptContext( | |
schemes=["pbkdf2_sha256"], | |
default="pbkdf2_sha256", | |
pbkdf2_sha256__default_rounds=30000 | |
) | |
# implementation | |
def encrypt_password(password): | |
return pwd_context.encrypt(password) | |
def check_encrypted_password(password, hashed): | |
return pwd_context.verify(password, hashed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment