C++ to c#

08/30/2012 16:50 ernilos#1
Hey! I tryed to make a login server in c++ but, I dont understand c++ and i think to make in c#.
In c++ have that:
Code:
		string login_packet;
		for (int i = 0; i < 255; i++) 
			{
				login_packet += (int)(recvbuf[i] - 15 ^ 195);
			}			
		cout << login_packet.c_str();
And in c# i have that:
Code:
            string login_packet = "";
            for (int i = 0; i < 255; i++)
            {
                login_packet += (int)(Buffer[i] - 15 ^ 195);
            }
But in c# it appears
[Only registered and activated users can see links. Click Here To Register...]
And in c++ it appears
[Only registered and activated users can see links. Click Here To Register...]

Help?
08/30/2012 20:45 nkkk#2
in c++ when you cast a int to a string you get the int interpretet as ascii or whatever,
but in C# you get the integer as a string:
C# code
Code:
string s = "";
s += 80
// s is now "80"
C++ code
Code:
string s = "";
s += 80
// s is now "P"
so in C# you have to use a encoding object like System.Text.UTF8Encoding
08/30/2012 22:21 ernilos#3
M.. I'm looking the object, but i don't find the class to convert.. Help? x.x
08/31/2012 00:22 Kraizy​#4
[Only registered and activated users can see links. Click Here To Register...]
08/31/2012 11:45 ernilos#5
Quote:
Originally Posted by xKraizy View Post
[Only registered and activated users can see links. Click Here To Register...]
....
On another post say's the class... Can help me with method to convert? I don't found .-.
09/02/2012 18:47 irrenhaus#6
Code:
//Decrypt Func//
void decrypt2(ref byte[] data)
{
    for (int i = 0; i < data.Length; i++)
    {
        data[i] = (byte)(data[i] - 15 ^ 195);
    }
}

//Convertierung zum String
string login_packet = Encoding.UTF8.GetString(Buffer);

//Beispiel:
byte[] Buffer = ...
decrypt(ref Buffer);
string login_packet = Encoding.UTF8.GetString(Buffer);
Console.WriteLine(login_packet);
sollte gehen.