<commit_before>#!/usr/bin/env python3

from libpals.util import (
    xor_find_singlechar_key,
    hamming_distance,
    fixed_xor,
    transpose
)

def test_xor_find_singlechar_key():
    input = '<KEY>'
    ciphertext = bytes.fromhex(input)
    result = xor_find_singlechar_key(ciphertext)
    assert result['key']  == 88
    assert result['plaintext']  == b"Cooking MC's like a pound of bacon"


def test_hamming_distance():
    assert hamming_distance(b"this is a test", b"wokka wokka!!!") == 37


def test_fixed_xor():
    input = bytes.fromhex("1c0111001f010100061a024b53535009181c")
    key = bytes.fromhex("686974207468652062756c6c277320657965")
    assert fixed_xor(input, key) == b"the kid don't play"


def test_transpose_2():
    chunks = [b'AN', b'BO', b'CP', b'DQ', b'ER', b'FS', b'GT', b'HU', b'IV',
              b'JW', b'KX', b'LY', b'MZ']
    assert transpose(chunks) == [b'ABCDEFGHIJKLM', b'NOPQRSTUVWXYZ']


def test_transpose_3():
    chunks = [b'AJS', b'BKT', b'CLU', b'DMV', b'ENW', b'FOX', b'GPY', b'HQZ',
              b'IR']
    assert transpose(chunks) == [b'ABCDEFGHI', b'JKLMNOPQR', b'STUVWXYZ']


def test_transpose_4():
    chunks = [b'AHOU', b'BIPV', b'CJQW', b'DKRX', b'ELSY', b'FMTZ', b'GN']
    assert transpose(chunks) == [b'ABCDEFG', b'HIJKLMN', b'OPQRST', b'UVWXYZ']<commit_msg>Renamed the Hamming distance test<commit_after>#!/usr/bin/env python3

from libpals.util import (
    xor_find_singlechar_key,
    hamming_distance,
    fixed_xor,
    transpose
)

def test_xor_find_singlechar_key():
    input = '<KEY>'
    ciphertext = bytes.fromhex(input)
    result = xor_find_singlechar_key(ciphertext)
    assert result['key']  == 88
    assert result['plaintext']  == b"Cooking MC's like a pound of bacon"


def test_hamming_distance_a():
    assert hamming_distance(b"this is a test", b"wokka wokka!!!") == 37


def test_fixed_xor():
    input = bytes.fromhex("1c0111001f010100061a024b53535009181c")
    key = bytes.fromhex("686974207468652062756c6c277320657965")
    assert fixed_xor(input, key) == b"the kid don't play"


def test_transpose_2():
    chunks = [b'AN', b'BO', b'CP', b'DQ', b'ER', b'FS', b'GT', b'HU', b'IV',
              b'JW', b'KX', b'LY', b'MZ']
    assert transpose(chunks) == [b'ABCDEFGHIJKLM', b'NOPQRSTUVWXYZ']


def test_transpose_3():
    chunks = [b'AJS', b'BKT', b'CLU', b'DMV', b'ENW', b'FOX', b'GPY', b'HQZ',
              b'IR']
    assert transpose(chunks) == [b'ABCDEFGHI', b'JKLMNOPQR', b'STUVWXYZ']


def test_transpose_4():
    chunks = [b'AHOU', b'BIPV', b'CJQW', b'DKRX', b'ELSY', b'FMTZ', b'GN']
    assert transpose(chunks) == [b'ABCDEFG', b'HIJKLMN', b'OPQRST', b'UVWXYZ']
{'fraction_non_alphanumeric': 0.17030896759608138, 'fraction_numerical': 0.055011303692539565, 'mean_word_length': 4.3420523138833, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1503874', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1108, 'n_words': 213}