Mercurial > wikked
view wikked/bcryptfallback.py @ 431:e4a06565ecd5
cm: Add Travis-CI config file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 30 Mar 2017 19:48:23 -0700 |
parents | 5ff3b1639154 |
children | 6c8f90e47338 |
line wrap: on
line source
import logging logger = logging.getLogger(__name__) try: from flask.ext.bcrypt import Bcrypt, generate_password_hash except ImportError: logger.warning("Bcrypt not available... falling back to SHA512.") logger.warning("Run `pip install Flask-Bcrypt` for more secure " "password hashing.") import hashlib def generate_password_hash(password): return hashlib.sha512(password.encode('utf8')).hexdigest() def check_password_hash(reference, check): check_hash = hashlib.sha512(check.encode('utf8')).hexdigest() return check_hash == reference class SHA512Fallback(object): def __init__(self, app=None): self.generate_password_hash = generate_password_hash self.check_password_hash = check_password_hash Bcrypt = SHA512Fallback