login about faq

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!

asked Jan 17 at 13:32

VYSE's gravatar image

VYSE
122

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×33
×8

Asked: Jan 17 at 13:32

Seen: 420 times

Last updated: Jan 17 at 13:32

powered by OSQA