# HG changeset patch # User Ludovic Chabant # Date 1442725274 25200 # Node ID 5ff3b16391548b7d025233e85757cd8ccfb1607a # Parent ece930a816b1c492ea9b98d9b2563b166459611b Fix bcrypt callback wrapper: * Use new-style `flask.ext` package. * Correctly encode strings when needed. diff -r ece930a816b1 -r 5ff3b1639154 wikked/bcryptfallback.py --- a/wikked/bcryptfallback.py Sat Sep 19 10:14:51 2015 -0700 +++ b/wikked/bcryptfallback.py Sat Sep 19 22:01:14 2015 -0700 @@ -3,19 +3,19 @@ logger = logging.getLogger(__name__) try: - from flaskext.bcrypt import Bcrypt, generate_password_hash - + 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.") + logger.warning("Run `pip install Flask-Bcrypt` for more secure " + "password hashing.") import hashlib def generate_password_hash(password): - return hashlib.sha512(password).hexdigest() + return hashlib.sha512(password.encode('utf8')).hexdigest() def check_password_hash(reference, check): - check_hash = hashlib.sha512(check).hexdigest() + check_hash = hashlib.sha512(check.encode('utf8')).hexdigest() return check_hash == reference class SHA512Fallback(object):