Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (29 sloc) 1.04 KB
from passlib.hash import pbkdf2_sha512
import re
__author__ = 'csuttles'
class Utils(object):
def hash_password(password):
hashes a password from login or register form
:param password: The sha512 password from login/register form
:return: sha512 -> pbkdf2_sha512encrypted password
return pbkdf2_sha512.hash(password)
def check_hashed_password(password, hashed_password):
checks that password user sent matches that of the database.
The db password is encrypted.
:param password: sha512 hashed password
:param hashed_password: pbkdf2_sha512 encrypted password
:return: True if match, False otherwise
return pbkdf2_sha512.verify(password, hashed_password)
def email_is_valid(email):
email_addr_matcher = re.compile(r'^[\w-]+@(?:[\w-]+\.)+[\w-]+$')
if email_addr_matcher.match(email):
return True
return False
You can’t perform that action at this time.