-1

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??

Blckknght
  • 100,903
  • 11
  • 120
  • 169
  • 1
    Are you decrypting triple DES, or AES? Triple DES and AES are different. – Nick ODell Jun 25 '23 at 00:09
  • In the documentation is: Script to decrypt PINBlock ISO Format 0 3DES – Patrick Vieira Santos Jun 25 '23 at 00:44
  • If you are trying to decrypt 3DES why are you using AES? That is like trying to use a German translator to translate a document written in Spanish. – John Coleman Jun 25 '23 at 00:56
  • actually I'm reading some tutorials because it's my first contact with Tripple Des Maybe this is more correct: key = '6B43C8417C9270F00DCED51EDDE68E11' pass1 = 'C9C4D04C21FC618F' key_hash = md5(key).digest() tdes_key = DES3.adjust_key_parity(key_hash) a = DES3.new(tdes_key, DES3.MODE_ECB) need to decrypt pass1. – Patrick Vieira Santos Jun 25 '23 at 01:05
  • At this point you are changing the question in the comments. This makes the question a moving target. Please ask one question and stick to it. – John Coleman Jun 25 '23 at 01:09

1 Answers1

0

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)