Archived Forum Post

Index of archived forum posts

Question:

CkCrypt2 AES ECB Decrypt Mismatch Result

Jan 17 '16 at 13:32

Hi,

I've tried to decrypt with CkCrypt2 in AES ECB mode, but I've seen mismatch results. Here is a comparison with result of PyCrypto:

from Crypto.Cipher import AES
import chilkat

key = "a7fc844d17f43955783d7d6f5df7eb4e"
encrypted = "94580470718169340263307737572683"
# if encrypted text is below, results are same
# encrypted = "17254167109852952554433383444434"
print len(encrypted)
# 32

crypt = chilkat.CkCrypt2()
crypt.UnlockComponent("Anything for 30-day trial.")
crypt.put_CryptAlgorithm("aes")
crypt.put_CipherMode("ecb")
crypt.put_KeyLength(256)
crypt.put_PaddingScheme(3)
crypt.put_EncodingMode("hex")
crypt.SetEncodedKey(key,"ascii")
decStr = crypt.decryptStringENC(encrypted.encode('hex'))
print len(decStr)
# 29
print (decStr.encode('hex'))
# 311f91fd74a37ed67bcaad776581e02ce9b61e125e3c197c0703e17420

cipher = AES.new(key, AES.MODE_ECB)
dec = cipher.decrypt(encrypted)
print dec.encode('hex')
# e131e01f91fd74a37ed67bcaad776581e02ce9b61e125e3c197c0703e17420c5

I'm not sure if it is caused by the padding scheme, ECB mode with 32 bytes of length encrypted text should have no padding problem. And with some data, the result is correct. Thanks!