<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> __version_info__ = ( '<STR_LIT:0>' , '<STR_LIT>' , '<STR_LIT:1>' ) <EOL> __version__ = '<STR_LIT:.>' . join ( __version_info__ ) <EOL> __author__ = '<STR_LIT>' <EOL> __license__ = '<STR_LIT>' <EOL> __copyright__ = '<STR_LIT>' <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> from werkzeug . security import safe_str_cmp <EOL> try : <EOL> import bcrypt <EOL> except ImportError as e : <EOL> print ( '<STR_LIT>' ) <EOL> raise e <EOL> from sys import version_info <EOL> PY3 = version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> <EOL> def generate_password_hash ( password , rounds = None ) : <EOL> '''<STR_LIT>''' <EOL> return Bcrypt ( ) . generate_password_hash ( password , rounds ) <EOL> def check_password_hash ( pw_hash , password ) : <EOL> '''<STR_LIT>''' <EOL> return Bcrypt ( ) . check_password_hash ( pw_hash , password ) <EOL> class Bcrypt ( object ) : <EOL> '''<STR_LIT>''' <EOL> _log_rounds = <NUM_LIT:12> <EOL> def __init__ ( self , app = None ) : <EOL> if app is not None : <EOL> self . init_app ( app ) <EOL> def init_app ( self , app ) : <EOL> '''<STR_LIT>''' <EOL> self . _log_rounds = app . config . get ( '<STR_LIT>' , <NUM_LIT:12> ) <EOL> def generate_password_hash ( self , password , rounds = None ) : <EOL> '''<STR_LIT>''' <EOL> if not password : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if rounds is None : <EOL> rounds = self . _log_rounds <EOL> if PY3 and isinstance ( password , str ) : <EOL> password = bytes ( password , '<STR_LIT:utf-8>' ) <EOL> if not PY3 and isinstance ( password , unicode ) : <EOL> password = password . encode ( '<STR_LIT:utf-8>' ) <EOL> return bcrypt . hashpw ( password , bcrypt . gensalt ( rounds ) ) <EOL> def check_password_hash ( self , pw_hash , password ) : <EOL> '''<STR_LIT>''' <EOL> if PY3 and isinstance ( pw_hash , str ) : <EOL> pw_hash = bytes ( pw_hash , '<STR_LIT:utf-8>' ) <EOL> if PY3 and isinstance ( password , str ) : <EOL> password = bytes ( password , '<STR_LIT:utf-8>' ) <EOL> if not PY3 and isinstance ( pw_hash , unicode ) : <EOL> pw_hash = pw_hash . encode ( '<STR_LIT:utf-8>' ) <EOL> if not PY3 and isinstance ( password , unicode ) : <EOL> password = password . encode ( '<STR_LIT:utf-8>' ) <EOL> return safe_str_cmp ( bcrypt . hashpw ( password , pw_hash ) , pw_hash ) </s>
