Skip to content

Instantly share code, notes, and snippets.

@0ex-d
Created August 20, 2020 08:30
Show Gist options
  • Save 0ex-d/8222b0edb2c1b5b2fbaba6114d510902 to your computer and use it in GitHub Desktop.
Save 0ex-d/8222b0edb2c1b5b2fbaba6114d510902 to your computer and use it in GitHub Desktop.
'''
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