Пример #1
0
def question_b():
    key_1 = (b'11100010'
             b'11110110'
             b'11011110'
             b'00110000'
             b'00111010'
             b'00001000'
             b'01100010'
             b'11011100')

    key_2 = (b'01100010'
             b'11110110'
             b'11011110'
             b'00110000'
             b'00111010'
             b'00001000'
             b'01100010'
             b'11011100')

    plain_text = (b'01101000'
                  b'10000101'
                  b'00101111'
                  b'01111010'
                  b'00010011'
                  b'01110110'
                  b'11101011'
                  b'10100100')

    crypto_1 = MyDES.encrypt(plain_text, key_1)
    crypto_2 = MyDES.encrypt(plain_text, key_2)

    print_encrypt(plain_text, key_1, crypto_1)
    print_encrypt(plain_text, key_2, crypto_2)
    print_diff(crypto_1, crypto_2)
def question_a():
    plain_text_1 = b"0" * 64
    plain_text_2 = b"1" + b"0" * 63
    key = b"00000010" b"10010110" b"01001000" b"11000100" b"00111000" b"00110000" b"00111000" b"01100100"

    crypto_1 = MyDES.encrypt(plain_text_1, key)
    crypto_2 = MyDES.encrypt(plain_text_2, key)

    print_encrypt(plain_text_1, key, crypto_1)
    print_encrypt(plain_text_2, key, crypto_2)
    print_diff(crypto_1, crypto_2)
def question_b():
    key_1 = b"11100010" b"11110110" b"11011110" b"00110000" b"00111010" b"00001000" b"01100010" b"11011100"

    key_2 = b"01100010" b"11110110" b"11011110" b"00110000" b"00111010" b"00001000" b"01100010" b"11011100"

    plain_text = b"01101000" b"10000101" b"00101111" b"01111010" b"00010011" b"01110110" b"11101011" b"10100100"

    crypto_1 = MyDES.encrypt(plain_text, key_1)
    crypto_2 = MyDES.encrypt(plain_text, key_2)

    print_encrypt(plain_text, key_1, crypto_1)
    print_encrypt(plain_text, key_2, crypto_2)
    print_diff(crypto_1, crypto_2)
    def test_usage(self):
        plain_text_1 = b"0" * 64
        plain_text_2 = b"1" + b"0" * 63

        key = b"00000010" b"10010110" b"01001000" b"11000100" b"00111000" b"00110000" b"00111000" b"01100100"

        # plain_text_1
        crypto_1 = MyDES.encrypt(plain_text_1, key)
        self.assertEqual(MyDES.decrypt(crypto_1, key), plain_text_1)

        # plain_text_2
        crypto_2 = MyDES.encrypt(plain_text_2, key)
        self.assertEqual(MyDES.decrypt(crypto_2, key), plain_text_2)

        self.assertNotEqual(crypto_1, crypto_2)
Пример #5
0
def question_a():
    plain_text_1 = b'0' * 64
    plain_text_2 = b'1' + b'0' * 63
    key = (b'00000010'
           b'10010110'
           b'01001000'
           b'11000100'
           b'00111000'
           b'00110000'
           b'00111000'
           b'01100100')

    crypto_1 = MyDES.encrypt(plain_text_1, key)
    crypto_2 = MyDES.encrypt(plain_text_2, key)

    print_encrypt(plain_text_1, key, crypto_1)
    print_encrypt(plain_text_2, key, crypto_2)
    print_diff(crypto_1, crypto_2)
    def test_usage(self):
        plain_text_1 = b'0' * 64
        plain_text_2 = b'1' + b'0' * 63

        key = (b'00000010'
               b'10010110'
               b'01001000'
               b'11000100'
               b'00111000'
               b'00110000'
               b'00111000'
               b'01100100')

        # plain_text_1
        crypto_1 = MyDES.encrypt(plain_text_1, key)
        self.assertEqual(MyDES.decrypt(crypto_1, key), plain_text_1)

        # plain_text_2
        crypto_2 = MyDES.encrypt(plain_text_2, key)
        self.assertEqual(MyDES.decrypt(crypto_2, key), plain_text_2)

        self.assertNotEqual(crypto_1, crypto_2)