login about faq


i'm using chilkatcrypt and want to encode/decode VB6 String messages whicht can contain all characters from 0 to 255.

dim s1 as string,s2 as string,s3 as string

crypt.CryptAlgorithm = "none"
crypt.EncodingMode = "hex" ' or "base64"
crypt.Charset = "unicodefffe"

s1 = ""
For ax = 0 To 255
 s1 = s1 + Chr(ax)
s2 = crypt.EncryptStringENC(s1)
s3 = crypt.DecryptStringENC(s2)
debug.print s1=s3

This sample works perfect for char ranges between 1 and 255, but if my String starts with chr(0) chilkat will return an empty result and no error message.

I tried all possible Encoding/Charset modes, but it doesn't help.

Is there any chance to encode/decode binary strings using base64 without having problems? (I want to use this to send data via TCP connections)

regards Hawk78

asked Mar 14 '13 at 08:55

Hawk78's gravatar image


The Chilkat API is provided for many different programming languages in many different environments. A "string" is very different than binary data. A "string" is a sequence of characters, each of which is associated with a glyph (such as "A", or "ら", or "Ω").

Each character in a string is a logical entity. To save a string to a file (or to bytes in memory), some sort of byte representation must be used. For example,

Consider this character: É

In the iso-8859-1 character encoding, it is represented by a single byte: 0xC9

In the utf-8 character encoding, it is represented by a two bytes: 0xC3 0x89

In the ucs-2 character encoding, it is represented by a two bytes: 0x00 0xC9

What you've done is to create a byte array (containing the byte values 0 through 255), and then inappropriately called it a "string". But you don't really have a string (even if VB6 calls it a CHR or "string"). Because Chilkat is offered in so many programming languages, it must be more strict about how it handles strings. If what you have are bytes that do not represent actual printable characters, then you should use the Chilkat methods for handling binary data, such as EncryptBytesENC.


answered Mar 18 '13 at 11:27

chilkat's gravatar image

chilkat ♦♦

This does look like a bug in ChilkatCrypt to me - if I put Chr$(0) anywhere except for the first character in the string to encode, the result is as expected (s1=s3). When the first character is Chr$(0), then the result is an empty string for s3 (even though the LastErrorText property reports success after encrypting and decrypting).


answered Mar 16 '13 at 14:33

jpbro's gravatar image

jpbro ♦

this is almost like what i face now. and as far as i know in vb6 keyascii chart, chr(0) will resulting NULL.(fix me if im wrong)

kinda need to make some another tricky perspective way.


answered Aug 06 '14 at 00:28

febfeb's gravatar image


If it's not actually a string (i.e. bytes that represent characters in some human language, according to some character encoding (utf-8, iso-8859-1, ebcdic, Shift-JIS, etc.), that are visually displayed as glyphs), then do not use the string methods (such as EncryptStringENC). Instead, use the byte methods, such as EncryptBytesENC.


answered Aug 06 '14 at 08:53

chilkat's gravatar image

chilkat ♦♦

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: Mar 14 '13 at 08:55

Seen: 3,725 times

Last updated: Aug 06 '14 at 08:53

powered by OSQA