Esempio n. 1
0
    def RuntimeTest(self):
        data = self.testData.strip().split('\n')
        for i in range(len(data)):

            start = time()

            des = DES()
            key = '0001001100110100010101110111100110011011101111001101111111110001'
            des.SetKey(key)
            des.EncryptKey()
            des.SetInputText(data[i])
            des.SetCipherText(des.Encrypt())
            desResult = des.Decrypt()

            stop = time()
            self.runtime += ('DES runtime:' + str(stop - start) + "s\n")

            start = time()

            rsa = RSA()
            rsa.KeyGeneration(128)
            rsaResult = rsa.Decryption(
                rsa.Encryption(int(data[i]), rsa.keyPublic, rsa.n),
                rsa.keyPrivate, rsa.n)

            stop = time()
            self.runtime += ('RSA runtime:' + str(stop - start) + "s\n\n")

        return self.runtime
Esempio n. 2
0
bin_pt_3 = ""
bin_ct_1 = ""
bin_ct_2 = ""
bin_ct_3 = ""
diff_P1P2 = ""
diff_P2P3 = ""
diff_P1P3 = ""
diff_C1C2 = ""
diff_C2C3 = ""
diff_C1C3 = ""

DES.KeyProNGen()
one_time_key = DES.info['key']
DES.info['PlainText'] = P1
DES.Encrypt()
DES.Decrypt()
bin_pt_1 = DES.info['PlainText_b']
C1 = DES.info['CipherText']
for i in C1:
    bin_ct_1 += ac.hex2bin(i)

DES.info['PlainText'] = P2
DES.Encrypt()
bin_pt_2 = DES.info['PlainText_b']
C2 = DES.info['CipherText']
for i in C2:
    bin_ct_2 += ac.hex2bin(i)

DES.info['PlainText'] = P3
DES.Encrypt()
bin_pt_3 = DES.info['PlainText_b']