Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.NET Compatible encryption library
Message
 
To
01/07/2009 04:02:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01407945
Message ID:
01410100
Views:
59
> rc4.EncryptionKey = "1234567890";

Your key better doesn't get any more complex than that. Here's the code the encyption library uses:
// Perform the conversion of the encryption key from unicode to ansi
byte[] asciiBytes = Encoding.Convert(unicode,ascii,unicode.GetBytes(this.m_sEncryptionKey));
I don't understand why you still see this over and over and over in .NET applications. Using a DOS compatible ASCII codepage in a Windows application and in claim to use ANSI in the comment. ASCII != ANSI, please....

What code page is your computer using? The .NET code breaks when you use an Asian codepage that support multibyte characters. The code uses Encoding.GetChars and Encoding.GetBytes as if those are reversible operations. They are, but only with Western codepages. This code doesn't work with Asian codepages. Here's a sample using the Korean codepage:
var x = new Byte[256];
for(var i=0; i<256; i++)
  x[i] = (Byte) i;

var e = Encoding.GetEncoding(50225); 
var y = e.GetBytes(new String(e.GetChars(x)));

for (var i = 0; i < 256; i++)
  if(y[i] != (Byte) i)
    Console.WriteLine(i);
If you run this you can see that one third of all byte values cannot be converted to a char and back to a byte. It works fine for 1252, 437, 1251, etc. though.
--
Christof
Previous
Reply
Map
View

Click here to load this message in the networking platform