Register for your free account! | Forgot your password?

You last visited: Today at 07:12

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C++ to c#

Discussion on C++ to c# within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
ernilos's Avatar
 
elite*gold: 20
Join Date: Jan 2012
Posts: 766
Received Thanks: 645
C++ to c#

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

And in c++ it appears


Help?
ernilos is offline  
Old 08/30/2012, 20:45   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 793
Received Thanks: 268
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
nkkk is offline  
Thanks
1 User
Old 08/30/2012, 22:21   #3
 
ernilos's Avatar
 
elite*gold: 20
Join Date: Jan 2012
Posts: 766
Received Thanks: 645
M.. I'm looking the object, but i don't find the class to convert.. Help? x.x
ernilos is offline  
Old 08/31/2012, 00:22   #4
 
Kraizy​'s Avatar
 
elite*gold: 0
The Black Market: 471/0/0
Join Date: Apr 2010
Posts: 9,696
Received Thanks: 1,810
Kraizy​ is offline  
Old 08/31/2012, 11:45   #5
 
ernilos's Avatar
 
elite*gold: 20
Join Date: Jan 2012
Posts: 766
Received Thanks: 645
Quote:
Originally Posted by xKraizy View Post
....
On another post say's the class... Can help me with method to convert? I don't found .-.
ernilos is offline  
Old 09/02/2012, 18:47   #6
 
irrenhaus's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 2,520
Received Thanks: 4,566
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.
irrenhaus is offline  
Reply




All times are GMT +2. The time now is 07:12.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.