Beispiel #1
0
def test_compare_ignores_random_letters():
    cipher = Fleissner(
        key="XooXooooooXoXoooXoooXXoXoooooooooXoXoooXooooXoooXoXoooXXoooooooo")

    ciphertext = cipher.encrypt("WELCOME TO VILLIERS PARK")
    assert cipher.compare_ciphertext(
        ciphertext,
        "WEHERRXSJQL C  POPVBMEA XTZRJRCKMTXOR Q NMMYVXGJIELAIOLIUB Q J Z")
Beispiel #2
0
def test_from_worksheet():
    cipher = Fleissner(
        key="XooXooooooXoXoooXoooXXoXoooooooooXoXoooXooooXoooXoXoooXXoooooooo")

    ciphertext = cipher.encrypt("WELCOME TO VILLIERS PARK")
    assert cipher.compare(
        "WEXEXRXSXXL CXXXOPXXMEA XXXRXXXKXTXOXXX XXXXVXXXIXLXXXLIXXXXXXXX",
        ciphertext), ciphertext
    plaintext = cipher.decrypt(
        "WEXEXRXSXXL CXXXOPXXMEA XXXRXXXKXTXOXXX XXXXVXXXIXLXXXLIXXXXXXXX")
    assert cipher.compare("WELCOME TO VILLIERS PARK", plaintext), plaintext

    ciphertext = cipher.encrypt("FLEISSNER IS A FUNNY NAME")
    assert cipher.compare_ciphertext(
        "FUHLINDNVXEYIRACS RNSNNEKEXAZZQMKRE BDGIENXPSZMN GAJKX FRTBUDSKC",
        ciphertext), ciphertext
    plaintext = cipher.decrypt(
        "FUHLINDNVXEYIRACS RNSNNEKEXAZZQMKRE BDGIENXPSZMN GAJKX FRTBUDSKC")
    assert cipher.compare_plaintext("FLEISSNER IS A FUNNY NAME",
                                    plaintext), plaintext
Beispiel #3
0
def test_hello():
    cipher = Fleissner(key="XooooXoXoooooXoo")
    assert "HXXOXEXLXXXXXLXX" == cipher.encrypt("HELLO")
    assert "HELLO" == cipher.decrypt("HXXOXEXLXXXXXLXX")
Beispiel #4
0
def test_very_large_plaintext():
    cipher = Fleissner(key="XooooXoXoooooXoo")
    ciphertext = cipher.encrypt("A" * 32)
    assert len(ciphertext) == 32