I have a problem with my application and DBCS operating system such as Japanese, Korean and Chinese Windows. Within SBCS Windows OS there is no problem within my program code, however, I have found that the encryption and decryption routines that I have coded for saving data reasonably securely do not work correctly under DBCS systems. It seems that the data gets written to the registry and is clipped before the actual end of information. I have expanded my encryption and decryption system to cope with the whole ASC() range of input values and I've also ensured that the encryption routine does not generated character 0 (which would act as a premature string terminator when writing the REG_SZ string).
Unfortunately I do not have access to a DBCS system myself and so debugging this issue is proving very difficult. The URL below is for a zip of my testing project which I'm using to try to overcome the problem.
The encryption method I'm using is to take the input character number, get the value of this MOD 128, then scramble this number which will be in the range of 0-127. However, I'm leaving out the 0 value from the scrambling process so that values in the range of 1-127 can not get mapped on to 0. A string of random letters is use to obtain ASC numbers used to shift and modulate the input ASC number. The starting point of the constant containing the random letters is generated randomnly and appended to the end of the encrypted text. The text is encrypted by taking the last to first letter as input, to reverse the order of text as well. Finally the encrypted text is encapsulated in asterisks for identification of encryption.
I find that my encryption and decryption routines run fine within the VB IDE and also the VB EXE. However, when I introduce the writing of the resultant encrypted data to the registry, a read back from the registry and the decryption of this information then I find that the text is either garbled or invalid encrypted information.
Could someone please run and debug the test project for me on a DBCS enabled system to find and highlight the problem, or alternatively let me know the reason behind the registry issue. I cannot see anything in MSDN that would suggest such behaviour. VB itself (I'm using Vb6Sp5) deals throughout in Unicode and the Registry values should accept this and write to the registry accordingly. It may perhaps be my registry routines at fault, although I can't easily debug this.
Any help very much appreciated, as currently any encrypted data in my program running on DBCS systems gets corrupted between write and read-back, subsequently causing errors, crashes or validity check failures.