[Python] What do I get from `flask-bcrypt` that I don't get from plain `bcrypt`?

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    Why would I use flask-bycrypt to hash user passowrds rather than plain old bcrypt? If the code below is correct I can see that the flask-bcrypt route requires a marginally simpler API, but I can't see what else it gives me. I'm asking because in my current app, if I go down the flask-bcrypt route, I'll have a couple of import issues to resolve and I want to know if it's worth the trouble.

    Using flask-bcrypt:

    from flask_bcrypt import Bcrypt
    from flask import Flask

    app = Flask(__name__)
    bcrypt = Bcrypt(app)
    bcrypt.generate_password_hash('12345')


    Using bcrypt:

    import bcrypt

    pw = '12345'.encode('utf-8')
    hashed_pw = bcrypt.hashpw(pw, bcrypt.gensalt())

    Continue reading...

Compartilhe esta Página