def hash_pwd(p): if isinstance(p, str): p = p.encode('utf-8') return bcrypt.hashpw(p, bcrypt.gensalt()).decode('ascii')