login about faq

What can be wrong?

crypt.CryptAlgorithm = "aes" crypt.CipherMode = "ecb" crypt.KeyLength = 192 crypt.PaddingScheme = 0 crypt.EncodingMode = "base64" Dim mykey As String mykey = "123456789012345678901234" crypt.SetEncodedKey mykey,"ascii" Dim encStr As String encStr = crypt.EncryptStringENC("alfa")

My result: HLsO0/FMvz31JO7Jyl8g6g==

But the correct result must be: E3HTU5mCfptLUwz034CfUZvBgXWk+iXC

Please help!!

asked May 23 at 07:02

Fureka's gravatar image

Fureka
3115


The first thing I notice is that your expected result is likely 32 bytes in size. (By eyeballing the base64 for Chilkat's result and your expected result, it seems that your expected result is twice the size.)

If you are encrypting "alfa", then it is either 4 bytes (in the us-ascii/utf-8 byte representation) or 8 bytes in the utf-16 representation. (Setting the crypt.Charset property controls the byte representation of the string that is to be encrypted.) In both cases (4 or 8 bytes), the output should be padded to the block size of the algorithm. The block size of AES is 16 bytes (regardless of key size), so the expected output SHOULD be 16 bytes. Your expected result is twice that length, which makes no sense.

link

answered May 23 at 08:50

chilkat's gravatar image

chilkat ♦♦
12.8k317363471

Thanks for your answer. You wrote: "The expected output should be 16 bytes". But my output string is 24 bytes long. What should i change in my code for the correct 16 byte output?

Thanks

link

answered May 23 at 09:49

Fureka's gravatar image

Fureka
3115

Your answer
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:

×73
×40

Asked: May 23 at 07:02

Seen: 252 times

Last updated: May 23 at 09:49

powered by OSQA