import re
import hashlib

"""
Some useful functions
"""

def title_to_url(title):
    url = re.sub(r'([^\s\w]|_)+', '', title).lower()
    url = ' '.join(url.split()) \
            .strip(' ') \
            .replace(' ','-')
    return url

def password_match_hash(input, hashed_password):
    hashed_input = hashlib.sha512(input).hexdigest()
    return True if hashed_input == hashed_password else False
