C
Curt Fluegel
I seem to be having a problem base64 encoding characters above 127. I
can encode a sentence like "The big bad dog" without problems, but if
I try to encode something like 0xFF I get different results than in
Perl.
For example I am using:
byte[] binaryArray =
System.Text.ASCIIEncoding.ASCII.GetBytes(binaryString);
string pushString = System.Convert.ToBase64String(binaryArray);
MessageBox.Show(pushString);
For 0xFF I get the result: Pw== which doesn't match my results in
Perl.
If it helps, I am converting a HEX input from a string, like FFE0 etc
with the following:
for (int i=0;i<hexString.Length;i=i+2)
{
string tmpstr = (((char)hexString).ToString()+((char)hexString
[i+1]).ToString());
int hex = Convert.ToInt32(tmpstr,16);
binaryString += (char)hex;
}
I run into problems with ASCII.GetBytes()
It seems it takes my 255 for FF and turns it into 127
If I use Unicode instead I get 255, but it uses two spots in the byte
array, like
255 0
Essentially I need FFFFFFFF as an input to turn into a byte array of:
255 255 255 255 255 255 255 255
Any ideas?
Thanks,
Curt
can encode a sentence like "The big bad dog" without problems, but if
I try to encode something like 0xFF I get different results than in
Perl.
For example I am using:
byte[] binaryArray =
System.Text.ASCIIEncoding.ASCII.GetBytes(binaryString);
string pushString = System.Convert.ToBase64String(binaryArray);
MessageBox.Show(pushString);
For 0xFF I get the result: Pw== which doesn't match my results in
Perl.
If it helps, I am converting a HEX input from a string, like FFE0 etc
with the following:
for (int i=0;i<hexString.Length;i=i+2)
{
string tmpstr = (((char)hexString).ToString()+((char)hexString
[i+1]).ToString());
int hex = Convert.ToInt32(tmpstr,16);
binaryString += (char)hex;
}
I run into problems with ASCII.GetBytes()
It seems it takes my 255 for FF and turns it into 127
If I use Unicode instead I get 255, but it uses two spots in the byte
array, like
255 0
Essentially I need FFFFFFFF as an input to turn into a byte array of:
255 255 255 255 255 255 255 255
Any ideas?
Thanks,
Curt