<commit_before>import time
import datetime
import re
import jinja2
import os
from base64 import b64encode
import hashlib
import json
from parse_datetime import *
import calendar
from yastlib import *
from google.appengine.api import users
from google.appengine.ext import ndb
import webapp2

DEFAULT_USER_ID = 'guest'
DEFAULT_CONTRACTOR_ID = 'guest'

def enhash(text, salt, hash_func):
	password_hash = hashlib.sha256(salt + text).hexdigest()
	return text

def user_password_key(user_id=DEFAULT_USER_ID):
	return ndb.Key('UserPassword', user_id)

class UserPassword(ndb.Model):
	password = ndb.StringProperty(indexed=False)
	salt = ndb.StringProperty(indexed=False)
	hash_func = ndb.StringProperty(indexed=False)
	
def get_user_password_info(user_id):
	user_password_query = UserPassword.query(ancestor=user_password_key(user_id))
	user_password_infos = user_password_query.fetch(1)
	if len(user_password_infos) > 0:
		return user_password_infos[0]
	else:<commit_msg>Enable hashing and salting of passwords<commit_after>import time
import datetime
import re
import jinja2
import os
from base64 import b64encode
import hashlib
import json
from parse_datetime import *
import calendar
from yastlib import *
from google.appengine.api import users
from google.appengine.ext import ndb
import webapp2

DEFAULT_USER_ID = 'guest'
DEFAULT_CONTRACTOR_ID = 'guest'

def enhash(text, salt, hash_func):
	password_hash = hashlib.sha256(salt + text).hexdigest()
	return password_hash

def user_password_key(user_id=DEFAULT_USER_ID):
	return ndb.Key('UserPassword', user_id)

class UserPassword(ndb.Model):
	password = ndb.StringProperty(indexed=False)
	salt = ndb.StringProperty(indexed=False)
	hash_func = ndb.StringProperty(indexed=False)
	
def get_user_password_info(user_id):
	user_password_query = UserPassword.query(ancestor=user_password_key(user_id))
	user_password_infos = user_password_query.fetch(1)
	if len(user_password_infos) > 0:
		return user_password_infos[0]
	else:
{'fraction_non_alphanumeric': 0.0792280345352971, 'fraction_numerical': 0.01218892839004571, 'mean_word_length': 7.277310924369748, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4340252', 'n_tokens_mistral': 691, 'n_tokens_neox': 665, 'n_words': 152}