login about faq

I have the latest one month trial chilkat dll version file for encryption. I encrypted the message using AES where key length is 128 using 'EncryptStringENC' function. I was also able to decrypt the message successfully, but I got some extra unreadable characters at the end of decrypted message. I did some test cases and came to know that these extra characters are appended by the 'EncryptStringENC' function. I want to remove these extra characters. Please let me know how can I achieve this.

Dim lastkeylen As Integer
lastkeylen = 128
crypt.Charset = "utf-8"
crypt.CryptAlgorithm = "aes"
crypt.CipherMode = "cbc"
crypt.KeyLength = lastkeylen

'  Generate random bytes and return the random bytes
'  in a hex string:
crypt.EncodingMode = "base64"
Dim randomKey As String
Dim keylen As Integer
keylen = 16
randomKey = crypt.GenRandomBytesENC(keylen)

Text1.Text = Text1.Text & "AES Key: " _
     & randomKey & vbCrLf

'  Set the key.
crypt.SetEncodedKey randomKey, "base64"
txtSecretKey.Text = txtSecretKey.Text & randomKey

    crypt.EncodingMode = "base64"
    Dim encryptedText As String                                                                                                                                                                                                                         
    encryptedText = crypt.EncryptStringENC("000012$1234 5678 9012 3456")
    Text1.Text = Text1.Text & "AES Key: " _
     & randomKey & vbCrLf

    If (success <> 1) Then
        Text1.Text = Text1.Text & crypt.LastErrorText & vbCrLf
        Exit Sub
    End If

And decrypted text message is as follows: decrypted text

Note: The encryption is part is done through a Visual Basic 6.0 application where we use your chilkat libraries, but the decryption part is done through a Java application using java crypto library. My vendor will purchase your encryption dll after this implementation. Please help me ASAP.

And also let me if any chat session available to discuss this. Its very urgent.

asked Dec 01 '14 at 00:22

Amit%20Raj's gravatar image

Amit Raj

edited Dec 01 '14 at 01:53


AES is a block encryption algorithm. All block encryption algorithms (AES, Blowfish, Twofish, DES/3DES, etc.) operate on a particular block-size that is specific to the algorithm. AES encrypts/decrypts in 16-byte blocks. This is the "block size" of the algorithm. Input can be any length, but encrypted output will always be a multiple of the block size. It is padded according to the crypt.PaddingScheme property. The default padding scheme is what you are seeing: Each byte (0x0E) indicates how many bytes of padding exists. When decrypting, an AES implementation should also unpad (after decrypting) to return the exact bytes that were encrypted. Whatever you are using to decrypt is not unpadding. You could work around the problem by changing the crypt.PaddingScheme to the value that pads with SPACE chars, and then you could trim the extra SPACE chars from the decrypted string.


answered Dec 01 '14 at 09:07

chilkat's gravatar image

chilkat ♦♦

It works for me

(Dec 02 '14 at 01:55) Amit Raj
Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: Dec 01 '14 at 00:22

Seen: 1,331 times

Last updated: Dec 02 '14 at 01:55

powered by OSQA