Question:
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!!
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.
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