Python - Decrypt Tripple Des AES - ECB

87 views Asked by At

I need to perform a decryption using TripleDes, I'm using Python - Crypto.Cipher import AES

Goodnight,

I'm trying to decrypt a 3Des key, but without success.

I'm doing it like this:

m = md5(key.encode('ISO-8859-1')).digest()
cipher = AES.new(m, AES.MODE_ECB)

Then I try to do the decryption:

x = bytes(password, 'ISO-8859-1')
b = cipher.decrypt(x)

It should return something like

0412719876FEDCBA

But it returns:

b'\x1e\xec\xd6A\xb13\xcf\x14N9\xa3\xb6\xdfZ\xf5\xbe'

In hexadecimal:

ac6b1433d25c07bd3853b293cbf719db

I know it's kind of vague, but does anyone have any light??

1

There are 1 answers

0
Patrick Vieira Santos On

Soluction

        key = '6B43C8417C9270F00DCED51EDDE68E11'
        binaryText = binascii.unhexlify(key)

        text = 'C9C4D04C21FC618F'
        text = binascii.unhexlify(str.encode(text, 'Utf-8'))

        k = pyDes.triple_des(binaryText, pyDes.ECB)
        ret = k.decrypt(text)
        print("Descrypt Value = %r" % binascii.hexlify(ret))
        print('@@@@@@@@@@@@@@@@@@@@')

xor

        a = binascii.hexlify(encrypted)
        pk = a.decode('iso-8859-1')
        x = pk.upper()
        print(x)
        x1 = x
        x2 = '0000456789012345' #card pan format
        a = [( ord (a) ^ ord (b)) for a , b in zip(x1 , x2)]
        print(a)