| 1 |
[](https://github.com/maxcountryman/flask-bcrypt/actions) |
| 2 |
[](https://pypi.python.org/pypi/Flask-Bcrypt) |
| 3 |
[](https://pypi.python.org/pypi/Flask-Bcrypt) |
| 4 |
|
| 5 |
# Flask-Bcrypt |
| 6 |
|
| 7 |
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for |
| 8 |
your application. |
| 9 |
|
| 10 |
Due to the recent increased prevalence of powerful hardware, such as modern |
| 11 |
GPUs, hashes have become increasingly easy to crack. A proactive solution to |
| 12 |
this is to use a hash that was designed to be "de-optimized". Bcrypt is such |
| 13 |
a hashing facility; unlike hashing algorithms such as MD5 and SHA1, which are |
| 14 |
optimized for speed, bcrypt is intentionally structured to be slow. |
| 15 |
|
| 16 |
For sensitive data that must be protected, such as passwords, bcrypt is an |
| 17 |
advisable choice. |
| 18 |
|
| 19 |
## Installation |
| 20 |
|
| 21 |
Install the extension with one of the following commands: |
| 22 |
|
| 23 |
$ easy_install flask-bcrypt |
| 24 |
|
| 25 |
or alternatively if you have pip installed: |
| 26 |
|
| 27 |
$ pip install flask-bcrypt |
| 28 |
|
| 29 |
## Usage |
| 30 |
|
| 31 |
To use the extension simply import the class wrapper and pass the Flask app |
| 32 |
object back to here. Do so like this: |
| 33 |
|
| 34 |
from flask import Flask |
| 35 |
from flask_bcrypt import Bcrypt |
| 36 |
|
| 37 |
app = Flask(__name__) |
| 38 |
bcrypt = Bcrypt(app) |
| 39 |
|
| 40 |
Two primary hashing methods are now exposed by way of the bcrypt object. Use |
| 41 |
them like so: |
| 42 |
|
| 43 |
pw_hash = bcrypt.generate_password_hash('hunter2') |
| 44 |
bcrypt.check_password_hash(pw_hash, 'hunter2') # returns True |
| 45 |
|
| 46 |
## Documentation |
| 47 |
|
| 48 |
The Sphinx-compiled documentation is available here: https://flask-bcrypt.readthedocs.io/ |