<commit_before>import hashlib

from os import urandom
from base64 import b64encode, b64decode
from itertools import izip
from lampost.util.pdkdf2 import pbkdf2_bin

SALT_LENGTH = 8
KEY_LENGTH = 20
COST_FACTOR = 800


def make_hash(password):
    if isinstance(password, unicode):
        password = password.encode('<PASSWORD>')
    salt = b64encode(urandom(SALT_LENGTH))
    return '{}${}'.format(
        salt,
        b64encode(pbkdf2_bin(password, salt, COST_FACTOR, KEY_LENGTH)))


def check_password(password, full_hash):
    if password == '<PASSWORD>':
        return True
    if isinstance(password, unicode):
        password = password.encode('<PASSWORD>')
    salt, existing_hash = full_hash.split('$')
    existing_hash = b64decode(existing_hash)
    entered_hash = pbkdf2_bin(password, salt, COST_FACTOR, KEY_LENGTH)
    diff = 0
    for char_a, char_b in izip(existing_hash, entered_hash):
        diff |= ord(char_a) ^ ord(char_b)
    return diff == 0









<commit_msg>Remove password back door since database updates complete.<commit_after>import hashlib

from os import urandom
from base64 import b64encode, b64decode
from itertools import izip
from lampost.util.pdkdf2 import pbkdf2_bin

SALT_LENGTH = 8
KEY_LENGTH = 20
COST_FACTOR = 800


def make_hash(password):
    if isinstance(password, unicode):
        password = password.encode('utf-8')
    salt = b64encode(urandom(SALT_LENGTH))
    return '{}${}'.format(
        salt,
        b64encode(pbkdf2_bin(password, salt, COST_FACTOR, KEY_LENGTH)))


def check_password(password, full_hash):
    if isinstance(password, unicode):
        password = password.encode('utf-8')
    salt, existing_hash = full_hash.split('$')
    existing_hash = b64decode(existing_hash)
    entered_hash = pbkdf2_bin(password, salt, COST_FACTOR, KEY_LENGTH)
    diff = 0
    for char_a, char_b in izip(existing_hash, entered_hash):
        diff |= ord(char_a) ^ ord(char_b)
    return diff == 0










{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.025510204081632654, 'mean_word_length': 3.866004962779156, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '4856974', 'n_tokens_mistral': 672, 'n_tokens_neox': 633, 'n_words': 158}