#NEWLINE# def create_hash( userpwd ) : #NEWLINE# #INDENT# 'Given a password, create a key to be stored in the DB.' #NEWLINE# if ( not settings . HMAC_KEYS ) : #NEWLINE# #INDENT# raise ImportError ( 'settings.HMAC_KEYS must not be empty. Read the django_sha2 docs!' ) #NEWLINE# #UNINDENT# latest_key_id = max ( settings . HMAC_KEYS . keys ( ) ) #NEWLINE# shared_key = settings . HMAC_KEYS [ userpwd ] #NEWLINE# return '' . join ( ( 'bcrypt' , _bcrypt_create ( _hmac_create ( userpwd , shared_key ) ) , '$' , latest_key_id ) )