As usual I have a ‘off the wall’ question.
I have been fighting a problem with encryption to be used between a FEZ.Raptor and a Windows form.
I finally found the problem but I have no answer for it at the moment.
Root cause is that in some encrypted strings there may be a ‘\0’.
.NET strings seem to allow the ‘\0’. However .NET Micro does not. (At least in my code)?
Example:
public string EncryptString(string Data, string Key)
{
uint[] formattedKey = FormatKey(Key);
if (Data.Length % 2 != 0) // Make sure array has even length.
{
if(Data.Length %2 != 0)
{
Data += '\0'; //<This does not work. Data remains the same
}
}
......
......
}
//
.Net Micro
string a = string.Empty;
string b = string.Empty;
string c = string.Empty;
string d = string.Empty;
string e = string.Empty;
string f = string.Empty;
string g = string.Empty;
string h = string.Empty;
string i = string.Empty;
string j = string.Empty;
string k = string.Empty;
//character literals to strings
a += '\''; //Single quote
b += '\"'; //Double quote
c += '\\'; //Backslash
d += '\0'; //Null
e += '\a'; //Alert
f += '\b'; //Backspace
g += '\f'; //Form feed
h += '\n'; //New line
i += '\r'; //Carriage return
j += '\t'; //Horizontal tab
k += '\v'; //Vertical tab
//Resulting strings
a "'" string
b "\"" string
c "\\" string
d "" string <<<<
e "\a" string
f "\b" string
g "\f" string
h "\n" string
i "\r" string
j "\t" string
k "\v" string
.NET 4.5
//Resulting strings
a "'" string
b "\"" string
c "\\" string
d "\0" string <<<<
e "\a" string
f "\b" string
g "\f" string
h "\n" string
i "\r" string
j "\t" string
k "\v" string
Anyone know a way around this?
Thanks!