maxcountryman / flask-bcrypt

Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Home Page:http://readthedocs.org/docs/flask-bcrypt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: module 'bcrypt' has no attribute 'hashpw'

khadkarajesh opened this issue · comments

bcrypt.py

     from flask import Flask
     from flask_bcrypt import Bcrypt

     bcrypt = Bcrypt()

app.py

     from bcrypt import bcrypt
     bcrypt.init_app(app)

Uses in any file

     from bcrypt import bcrypt
     bcrypt.generate_password_hash('rajesh')
     Flask-Bcrypt==0.7.1

I'm running into the same issue here, also for Flask-Bcrypt==0.7.1

I originally thought it was a namespace issue per the documentation here:

Namespacing Issues
It’s worth noting that if you use the format, bcrypt = Bcrypt(app) you are effectively overriding the bcrypt module. Though it’s unlikely you would need to access the module outside of the scope of the extension be aware that it’s overriden.

Alternatively consider using a different name, such as flask_bcrypt = Bcrypt(app) to prevent naming collisions.

But, I'm still getting the same error even after renaming the variable from bcrypt to flask-bcrypt

that's because you use bcrypt.py module. You can rename it to something like security.py so it's not the same name as a site-package

Closing since this issue can't be fixed by changing Flask-Bcrypt.