Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EepTech

Encryption Trouble with UNICODE

This topic is 5274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing some encryption routines based off of a jscript webpage on arcfour encryption. I am having a problem getting the same results as the jscript is getting. The jscript of course uses UNICODE characters where C++ applications use ASCII characters (I am trying to convert the ASCII to UNICODE). In a particular instance (as shown in code below), I get the UNICODE character 142, but 142 has no ASCII equal (That is why I get the question mark character in the last two lines). Although, the jscript works fine. Is there some way to fix this? The original jscript is listed below the test c code. char c = ''0''; // int value of 48 wchar_t wc = 0; MultiByteToWideChar(CP_ACP, 0, &c, 1, &wc, 1); // At this point, (UNICODE)wc = 48 wc ^= 190; // This changes wc to 142 WideCharToMultiByte(CP_ACP, 0, &wc, 1, &c, 1, NULL, NULL); // After this call (ASCII)c becomes 63? MultiByteToWideChar(CP_ACP, 0, &c, 1, &wc, 1); // In an attempt to validate the problem, I added this line to make sure I get the same // value back in (UNICODE)wc. I don''t, I get 63 back. JScript var enc = InData.charCodeAt(j) ^ src; // InData.charCodeAt(j) = 48, j = 3, i = 9, src[i] = 190, enc // becomes 142 os = j + "\n" + i + "\n" + src[i] + "\n" + InData.charCodeAt(j) + "\n" + enc + "\n" + String.fromCharCode(enc) + "\n"; output += String.fromCharCode(enc); os output: 3 9 190 48 142 Ž // I don''t know what this character is, UNICODE or ASCII. If I paste it into debug in my c++ watch window it becomes // a ''?'' Is my c++ code an accurate conversion of the JScript code (minus the os that I added)?

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!