Пример #1
0
def decryptionECB(key, ciphertext):
	cipher = tl.h2b(ciphertext[0])
	result = ""
	for x in xrange(0, (len(cipher)/64)):
		result += aes.decryption(key, cipher[(x*64):(x*64+64)])

	result = tl.unPadding(result, ciphertext[1])
	return result
Пример #2
0
def decryptionCTR(key,ciphertext,original_Counter,padding_size):
    count = len(ciphertext)/16
    plain=''
    encryCounter_List = getCounter(tl.b2h(original_Counter),count,key)
    for i in xrange(0,count,1):
        plain+= str(tl.b2h(tl.xor(tl.h2b(encryCounter_List[i]),tl.h2b(ciphertext[i*16:(i*16)+16]))))
    plain = tl.unPadding(plain,padding_size) 
    return plain
Пример #3
0
def decryptionOFB(iv, key, ciphertext,padding_size):
	biCipher = ciphertext
	count = len(biCipher)/64
	plain = []
	for i in xrange(0,count,1):
		iv = tl.h2b(aes.encryption(key, iv))
		biC = ciphertext[i*64:(i*64)+64]
		plain += tl.xor(iv, biC)
	plainStr = tl.b2h(plain)
	plainStr = tl.unPadding(plainStr,padding_size)
	return plainStr
Пример #4
0
def decryptionCFB(key,ciphertext,iv):
	hexCipher = tl.h2b(ciphertext[0])
	count = len(tl.h2b(ciphertext[0]))/64
	plain = ''
	for i in xrange(0,count,1):

		key_plain = tl.h2b(aes.encryption(key,iv))

		p = tl.b2h(tl.xor(key_plain,hexCipher[i*64:(i*64)+64]))
		iv = hexCipher[i*64:(i*64)+64]
		plain += p
	plain = tl.unPadding(plain, ciphertext[1])
	return plain