Example #1
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
Example #2
0
def cryptanalysis_fleissner():
    ciphertexts = request.form.get("ciphertexts", "").strip().splitlines()
    plaintexts = request.form.get("plaintexts", "").strip().splitlines()
    key = request.form.get(
        "key",
        "XooXooooooXoXoooXoooXXoXoooooooooXoXoooXooooXoooXoXoooXXoooooooo")
    if request.method == "POST":
        cipher = Fleissner(key=key)
        plaintexts = [cipher.decrypt(c) for c in ciphertexts]
    return render_template(
        "cryptanalysis/fleissner.html",
        ciphertexts=ciphertexts,
        plaintexts=plaintexts,
        key=key,
    )
Example #3
0
def test_hello():
    cipher = Fleissner(key="XooooXoXoooooXoo")
    assert "HXXOXEXLXXXXXLXX" == cipher.encrypt("HELLO")
    assert "HELLO" == cipher.decrypt("HXXOXEXLXXXXXLXX")