def test_from_worksheet():
    cipher = Myszkowski(key="VILLIERS")

    ciphertext = cipher.encrypt("WELCOME TO VILLIERS PARK")
    assert cipher.compare("MLAEOOIRPLC VS ELR IKWTE", ciphertext), ciphertext
    plaintext = cipher.decrypt("MLAEOOIRPLC VS ELR IKWTE")
    assert cipher.compare("WELCOME TO VILLIERS PARK", plaintext), plaintext

    ciphertext = cipher.encrypt("HOW DO YOU SPELL MYSZKOWSKI")
    assert cipher.compare("OEK ODUPMZK W  SYSI  LO YLW HO S",
                          ciphertext), ciphertext
    plaintext = cipher.decrypt("OEK ODUPMZK W  SYSI  LO YLW HO S")
    assert cipher.compare("HOW DO YOU SPELL MYSZKOWSKI", plaintext), plaintext
Example #2
0
def create_diffie_messages(group):
    playfair = Playfair(key='LSCZGADKUORFXTHQNBEPYMWIV')
    myszkowski = Myszkowski(key='HELLMAN')
    fleissner = Fleissner(
        key='ooooooooooooXoooXoooXoXXXoooXXXoooooooooooXooooooXXooooXooooXoXX')
    trifid = Trifid(key='CSQY_UBNVDWKPGERLTZJOHFAXMI')

    messages = [
        'BAILEY WHITFIELD DIFFIE WAS BORN IN NINETEEN FOURTY FOUR',
        'WHIT WAS THE COCREATOR OF DIFFIE HELLMAN KEY EXCHANGE',
        'DIFFIE GRADUATED FROM MIT IN NINETEEN SIXTY FIVE',
        'WITHOUT BAILEYS WORK THE INTERNET WOULD NOT BE POSSIBLE',
        'NEW DIRECTIONS IN CRYPTOGRAPHY',
        'HE HELPED DEVELOP THE FUNDAMENTAL IDEAS BEHIND PUBLIC KEY CIPHERS'
    ]
    yield from create_activity_messages(group,
                                        [fleissner, myszkowski, playfair],
                                        trifid, messages)
Example #3
0
def create_rivest_messages(group):
    playfair = Playfair(key='PCGDAVESFOHMUWZLYNBRXKIQT')
    myszkowski = Myszkowski(key='CLIFFORD')
    fleissner = Fleissner(
        key='oXXXooXoooXoXoooXooooXooXooooXXooooXoooooooXooXoooooooXooooooooX')
    trifid = Trifid(key='AOGMPWEDZRCIBH_XTLVUQSNKYJF')

    messages = [
        'RONALD LINN RIVEST WAS BORN IN NINETEEN FOURTY SEVEN',
        'RIVEST IS ONE OF THE INVENTORS OF THE RSA ALGORITHM',
        'RON ALSO AUTHORED MANY OTHER ENCRYPTION ALGORITMS',
        'RONALD WORKS AS A CRYPTOGRAPHER AND INSTITUTE PROFESSOR AT MIT',
        'RIVEST WAS GIVEN A TURING AWARD IN TWO THOUSAND AND TWO',
        'RSA IS ONE OF THE FIRST PRACTICAL PUBLIC KEY CIPHERS IT IS USED EVERYWHERE'
    ]
    yield from create_activity_messages(group,
                                        [playfair, myszkowski, fleissner],
                                        trifid, messages)
Example #4
0
def create_tutte_messages(group):
    playfair = Playfair(key='KQSGLRYTWEUXBFPVDHMNZOCAI')
    myszkowski = Myszkowski(key='TUNNY')
    fleissner = Fleissner(
        key='oXXXooXXooXoXXooooooXooooooXoooooXooooooooooXXoXoXoooooooooXoooo')
    trifid = Trifid(key='_AWCDPYSEKQORNHBTLGJMVFIZXU')

    messages = [
        'WILLIAM THOMAS TUTTE WORKED AT BLETCHLEY PARK CRACKING GERMAN CIPHERS',
        'BILL WAS BORN IN SUFFOLK IN NINETEEN SEVENTEEN',
        'TUTTE WAS INSTRUMENTAL IN BREAKING THE GERMAN LORENZ CIPHER',
        'AN ALGEBRAIC THEORY OF GRAPHS',
        'TUTTE PERFORMED ONE OF THE GREATEST INTELLECTUAL FEATS OF WORLD WAR TWO',
        'UNLIKE IN THE MOVIE TUTTE DID NOT WORK DIRECTLY WITH TURING'
    ]
    yield from create_activity_messages(group,
                                        [myszkowski, fleissner, playfair],
                                        trifid, messages)
Example #5
0
def create_driscoll_messages(group):
    playfair = Playfair(key='CTOEFMUHYISAWNGQRZXLDKBVP')
    myszkowski = Myszkowski(key='ILLINOIS')
    fleissner = Fleissner(
        key='oooooooXXoooXoooXoXooooXXooooXoXooooXXooooooooXoXXooXXoooooooooo')
    trifid = Trifid(key='VAMZWXKSYONFTDUCHIBERGPJL_Q')

    messages = [
        'AGNES MEYER DRISCOLL WAS BORN IN EIGHTEEN EIGHTY NINE',
        'SHE WAS ALSO KNOWN AS MADAME X',
        'SHE WAS WITHOUT PEER AS A CRYPTANALYST',
        'DRISCOLL WORKED FOR THE US NAVY IN WORLD WAR ONE AND TWO',
        'SHE IS IN THE NATIONAL SECURITY AGENCYS HALL OF HONOR',
        'AGNES CRACKED JAPANESE NAVAL CODES INCLUDING THE RED AND BLUE BOOK CODES'
    ]
    yield from create_activity_messages(group,
                                        [fleissner, playfair, myszkowski],
                                        trifid, messages)
Example #6
0
def create_friedman_messages(group):
    playfair = Playfair(key='ADUQYKOMRETGVFHNWLXZCIPBS')
    myszkowski = Myszkowski(key='INDIANA')
    fleissner = Fleissner(
        key='oooXooooXXoXXooXXXooooXooooooooooooXoXoXXoXoXooooooooooooooooooX')
    trifid = Trifid(key='V_WLNJDOGRMHIPXKYQSETBZUAFC')

    messages = [
        'AMERICAS FIRST FEMALE CRYPTANALYST',
        'FRIEDMAN WAS BORN IN EIGHTEEN NINETY TWO',
        'CRACKED CODES AT RIVERBANK DURING WORLD WAR ONE',
        'USED CRYPTANALYSIS TO STOP SMUGGLING AND BOOTLEGGING',
        'SHE WORKED FOR THE US NAVY THE TREASURY DEPARTMENT AND THE COAST GUARD',
        'THE SHAKESPEAREAN CIPHERS EXAMINED'
    ]
    yield from create_activity_messages(group,
                                        [myszkowski, fleissner, playfair],
                                        trifid, messages)
Example #7
0
def create_babbage_messages(group):
    playfair = Playfair(key='SCQOGUERPBKVWYZFDAHIMTLNX')
    myszkowski = Myszkowski(key='ENGINE')
    fleissner = Fleissner(
        key='ooooooXoooooXooXooooooooXoXoXoXoooooooooXXXoXooXooXoooXoXoooXooo')
    trifid = Trifid(key='HFERKDGNOQVJTMYP_AXSUBZWLIC')

    messages = [
        'CHARLES BABBAGE WAS BORN IN THE YEAR SEVENTEEN HUNDRED AND NINETY ONE',
        'BABBAGE INVENTED THE IDEA OF A DIGITAL PROGRAMMABLE COMPUTER',
        'CB IS CONSIDERED TO BE ONE OF THE FATHERS OF THE COMPUTER',
        'HIS MOST FAMOUS INVENTION IS THE DIFFERENCE ENGINE',
        'ON THE ECONOMY OF MACHINERY AND MANUFACTURES',
        'BABBAGE CRACKED THE UNCRACKABLE VIGENERE CIPHER',
    ]
    yield from create_activity_messages(group,
                                        [playfair, myszkowski, fleissner],
                                        trifid, messages)
def test_hello_small_key():
    cipher = Myszkowski(key="HI")
    #                        HELLO
    assert "HLOEL_" == cipher.encrypt("HELLO")
    assert "HELLO" == cipher.decrypt("HLOEL ")
def test_hello():
    cipher = Myszkowski(key="VILLIERS")
    #                        HELLO
    assert "_EOLL__H" == cipher.encrypt("HELLO")
    assert "HELLO" == cipher.decrypt(" EOLL  H")
def test_pad_two_rows():
    cipher = Myszkowski(key="ABC")
    assert "AAAA__" == cipher.pad("AAAA")
def test_hello_with_hello():
    cipher = Myszkowski(key="HELLO")
    assert "EHLLO" == cipher.encrypt("HELLO")
    assert "HELLO" == cipher.decrypt("EHLLO")
def test_pad_nothing_needed():
    cipher = Myszkowski(key="ABC")
    assert "AAA" == cipher.pad("AAA")
def test_pad():
    cipher = Myszkowski(key="ABC")
    assert "A__" == cipher.pad("A")
def test_compare():
    cipher = Myszkowski()
    assert cipher.compare("A", "A  ")
def test_key_too_small():
    with pytest.raises(ScytaleError):
        Myszkowski(key="A")
def test_key_blank():
    with pytest.raises(ScytaleError):
        Myszkowski(key="")