Re: Xor Cipher - Revisited
Hi Dilettante,
Since you're being rather precise here, it's worth pointing out that the VB6 internal (memory) handling of strings (treated as text) is actually the UCS-2 subset of the UTF-16 character-set (with LE (little endian) or BE (big endian) being yet another separate issue). The full UTF-16 (LE or BE) is capable of handling characters that are sometimes longer than two bytes.
There is much mis-information on the interwebbies about this, such as this page which is wrong. However, Wikipedia has it correct. As stated by Wikipedia, the full UTF-16 characterset (which is not natively supported by VB6) can support 1,112,064 possible characters, which is far more than a maximum allowed by two bytes.
Best Regards,
Elroy
EDIT1: Just as some more FYI, the mono-languages support the full UTF-16 specification. Also, Microsoft, to some degree has attempted to co-op the word "Unicode" and use it in this UCS-2 subset of UTF-16. However, originally, "Unicode" referred to all the attempts to encode extended character-sets beyond the original one-byte ASCII/ANSI standard.
Re: Xor Cipher - Revisited
Microsoft hasn't co-opted anything. Unicode is a separate concept from any specific representation in an encoding. I'm pretty sure the author of the second linked article above attempts to make that point.
The "supplementary planes" that drive UTF-16 encodings to 32 bits are seldom used but I agree it is useful to be aware of them. However you will have to dig deep to find anything in the Windows SDK that refers to UCS-2 rather than using the term UTF-16 instead. So if you want to split hairs you are correct, but it won't get you too far in accomplishing much.
This does mean it can be clumsy to work with characters like that in VB6 because ChrW$() and friends are limited to 16-bit values. But it is a rare program that needs to. Clumping around pretending ANSI encodings are ASCII is far more hazardous. So-called "extended ASCII" is really just the old OEM-US (codepage 437) from the MS-DOS era and it doesn't even use the same character set as Windows Western ANSI (codepage 1252).
However all I was trying to illustrate is how people often go wrong trying to write simple "Xor encryption" programs. They get in just as much trouble trying to double-convert hoping to squeeze through implicit encoding conversions in VB6.
Re: Xor Cipher - Revisited
Hi Dilettante,
Yep, I think it's excellent that you pointed out some of the potential pitfalls of XOR encoding with VB6 string data. And, as pointed out above, full use of UTF-16 isn't entirely dead. There are still many implementations of mono being used (which does implement the full UTF-16). One rather active and publicly used example is the little C-based Linden Scripting Language used in their online Second-Life platform.
And the reason I suggest that Microsoft is possibly co-opting the word Unicode is because of statements like the following:
Quote:
Originally Posted by
dilettante
It converts Unicode text to UTF-8
I believe those are your words, but its not difficult to find similar statements on Microsoft pages. That sentence is saying that we converted "some color to red". What if it was already red to begin with? IMHO, it's just Microsoft confusing things, as they often do.
All The Best,
Elroy
Re: Xor Cipher - Revisited