Last active
August 29, 2015 14:26
-
-
Save joshfriend/1baea89af56045c428f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from flask import current_app | |
from werkzeug.security import ( | |
generate_password_hash, | |
check_password_hash, | |
DEFAULT_PBKDF2_ITERATIONS, | |
) | |
class PBDKF2(object): | |
def __init__(self, app=None): | |
if app is not None: # pragma: no cover | |
self.init_app(app) | |
def init_app(self, app): | |
# Configure default app settings | |
app.config.setdefault('PBDKF2_METHOD', 'sha1') | |
app.config.setdefault('PBKDF2_ITERATIONS', DEFAULT_PBKDF2_ITERATIONS) | |
app.config.setdefault('PBDKF2_SALT_LENGTH', 8) | |
def generate_password_hash(self, password): | |
method = 'pbkdf2:{}:{}'.format(current_app.config['PBDKF2_METHOD'], | |
current_app.config['PBKDF2_ITERATIONS']) | |
return generate_password_hash(password, method, | |
current_app.config['PBDKF2_SALT_LENGTH']) | |
def check_password_hash(self, pwhash, password): | |
return check_password_hash(pwhash, password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment