Ejemplo n.º 1
0
    def test_column_decipher2(self):
        expected = "AMIDSUMMERNIGHTSDREAM"
        encrypted = "SIEIRDDNRMHMUGAAMTMES"
        key = "SWINDON"

        result = Cipher.column_decipher(encrypted, key)
        self.assertEquals(expected, result)
Ejemplo n.º 2
0
    def test_rail_fence_encipher_h4(self):
        expected = "KGRORAYTAIPF"

        message = "KRYPTOGRAFIA"

        result = Cipher.railFence_encipher(message, h=4)
        self.assertEquals(expected, result)
Ejemplo n.º 3
0
    def test_column_decipher(self):
        expected = "PIERWSZYM PARAMETREM SZYFRU KOLUMNOWEGO JEST LICZBA"
        encrypted = "RROAFGAPYEB ZWZMSOCY NIZMMLSEU WRLTRTOSEEKEIM JPAU "
        key = "JIHGFĘEDĆCBĄA"

        result = Cipher.column_decipher(encrypted, key)
        self.assertEquals(expected, result)
Ejemplo n.º 4
0
    def test_rail_fence_encipher_h3(self):
        expected = "SROWN   TŻOZF ŁTOYZAYBŁJŻWSAOYNŚIYPK NYU RTC"

        message = "SZYFR PŁOTKOWY ZNANY BYŁ JUŻ W STAROŻYTNOŚCI"

        result = Cipher.railFence_encipher(message, h=3)
        self.assertEquals(expected, result)
Ejemplo n.º 5
0
    def test_matrix_encipher_w3(self):
        expected = "SFKZRWY ADTYRO AWNAWYZA YNJE KSTŻTAE CRMIZAEOW==Y==M=="

        message = "SZYFR KWADRATOWY NAZYWANY JEST TAKŻE MACIERZOWYM"

        result = Cipher.matrix_cipher(message, w=3)
        self.assertEquals(expected, result)
Ejemplo n.º 6
0
    def test_cesar_decipher(self):
        expected = "SZYFR CEZARA JEST PRZYKŁADEM SZYFRU PRZESUWAJĄCEGO"
        encrypted = "TŻŹHŚ DFŻBŚB LFTV RŚŻŹŁNBĘFŃ TŻŹHŚW RŚŻFTWYBLCDFIP"
        key = 2

        result = Cipher.cesar(encrypted, -key)
        self.assertEquals(expected, result)
Ejemplo n.º 7
0
    def test_vigenere_decipher(self):
        expected = "TEN SZYFR JEST PODOBNY DO SZYFRU Z KODEM JEDNORAZOWYM"
        encrypted = "TĘO SŹŹFS LEŚV PÓĘOCOY EP SŹŹFSW Z LPDĘŃ JĘĘNÓŚAŹPWZŃ"
        key = "AĄB"
        m = len(key)

        result = Cipher.vigenere_decipher(encrypted, key, m)
        self.assertEquals(expected, result)
Ejemplo n.º 8
0
def zad_3():
    encrypted = "ZAŁNKAIPKAEAOWDNRYDWKLIMAZOOU"

    for i in range(2, len(encrypted)):  # 4
        result = Cipher.railFence_decipher(encrypted, i)
        # print(i)
        # print(result)

    result2 = Cipher.railFence_decipher(encrypted, 4)
    print("pkt 2")
    print(result2)

    result3 = Cipher.railFence_encipher(result2, 2)
    print("pkt 3")
    print(result3)

    result4 = Cipher.cesar(result2)
    print("pkt 4")
    print(result4)
Ejemplo n.º 9
0
def zad_2():
    message = "LICZBA WYSOCE ZŁOŻONA"

    result1 = Cipher.railFence_encipher(message, 3)
    print("1")
    print(result1)

    result2 = Cipher.matrix_cipher(message, 3)
    print("2")
    print(result2)

    result3 = Cipher.column_encipher(message, "NWD")
    print("3")
    print(result3)

    result4 = Cipher.vigenere_encipher(message, "NWW", len("NWW"))
    print("4")
    print(result4)

    result5 = Cipher.cesar(message)
    print("5")
    print(result5)
Ejemplo n.º 10
0
    def test_column_encipher_pi_n(self):
        expected = "RROAFGAPYEB ZWZMSOCY NIZMMLSEU WRLTRTOSEEKEIM JPAU "
        message = "PIERWSZYM PARAMETREM SZYFRU KOLUMNOWEGO JEST LICZBA"
        pi = {
            0: 12,
            1: 11,
            2: 10,
            3: 9,
            4: 8,
            5: 7,
            6: 6,
            7: 5,
            8: 4,
            9: 3,
            10: 2,
            11: 1,
            12: 0,
        }
        n = 13

        result = Cipher.column_encipher_pi_n(message, pi, n)
        self.assertEquals(expected, result)
Ejemplo n.º 11
0
    def test_matrix_decipher_w3(self):
        expected = "SZYFR KWADRATOWY NAZYWANY JEST TAKŻE MACIERZOWYMAĄBCĆD"
        encrypted = "SFKZRWY ADTYRO AWNAWYZA YNJE KSTŻTAE CRMIZAEOWACYĄĆMBD"

        result = Cipher.matrix_cipher(encrypted, w=3)
        self.assertEquals(expected, result)
Ejemplo n.º 12
0
    def test_rail_fence_decipher_h4(self):
        expected = "KRYPTOGRAFIA"
        encrypted = "KGRORAYTAIPF"

        result = Cipher.railFence_decipher(encrypted, h=4)
        self.assertEquals(expected, result)