<commit_before>import crypt
import hashlib


def __hashlib_hash(algo, password):
    h = hashlib.new(algo)
    h.update(password)
    return h.hexdigest()


def hashpw(algo, password):
    if algo == 'raw-md5':
        return __hashlib_hash('md5', password)
    elif algo == 'raw-sha1':
        return __hashlib_hash('sha1', password)
    elif algo == 'raw-sha256':
        return __hashlib_hash('sha256', password)
    elif algo == 'raw-sha512':<commit_msg>encode passwords as UTF-8 before hashing<commit_after>import crypt
import hashlib


def __hashlib_hash(algo, password):
    h = hashlib.new(algo)
    h.update(password.encode('utf-8'))
    return h.hexdigest()


def hashpw(algo, password):
    if algo == 'raw-md5':
        return __hashlib_hash('md5', password)
    elif algo == 'raw-sha1':
        return __hashlib_hash('sha1', password)
    elif algo == 'raw-sha256':
        return __hashlib_hash('sha256', password)
    elif algo == 'raw-sha512':
{'fraction_non_alphanumeric': 0.132429614181439, 'fraction_numerical': 0.029197080291970802, 'mean_word_length': 3.4651162790697674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7183231', 'n_tokens_mistral': 341, 'n_tokens_neox': 320, 'n_words': 76}