Exemplo n.º 1
0
 def encryption(self):
     out1 = self.des1.ecb_encryption()
     des2 = DES(self.key_list[1], out1)
     out2 = des2.ecb_encryption()
     des3 = DES(self.key_list[2], out2)
     result = des3.ecb_encryption()
     return result
Exemplo n.º 2
0
class TriDES:
    def __init__(self, key_list, input_str):
        self.key_list = key_list
        self.des1 = DES(self.key_list[0], input_str)

    def encryption(self):
        out1 = self.des1.ecb_encryption()
        des2 = DES(self.key_list[1], out1)
        out2 = des2.ecb_encryption()
        des3 = DES(self.key_list[2], out2)
        result = des3.ecb_encryption()
        return result
Exemplo n.º 3
0
# Test 3
# Decryption of Test 2
init_key_bin_3 = hex_2_bin('133457799BBCDFF1')
init_str_3 = hex_2_bin('85e813540f0ab405')
des_3 = DES(init_key_bin_3, init_str_3)
text_3 = des_3.decryption(des_3.input_list[0])
print_bin(bin_2_hex(text_3))
print()

###################################
# Test 4
# ECB mode encryption
init_key_bin_4 = hex_2_bin('133457799BBCDFF1')
init_str_4 = hex_2_bin('0123456789ABCDEF0123456789ABCD')
des_4 = DES(init_key_bin_4, init_str_4)
text_4 = des_4.ecb_encryption()
print_bin(bin_2_hex(text_4))
print()

###################################
# Test 5
# ECB mode decryption
init_key_bin_5 = hex_2_bin('133457799BBCDFF1')
init_str_5 = hex_2_bin('85e813540f0ab405ecc1a6e177f393b1')
des_5 = DES(init_key_bin_5, init_str_5)
text_5 = des_5.ecb_decryption()
print_bin(bin_2_hex(text_5))
print()

###################################
# Test 6