Solved

Sockets ASCII & Base64 Encryption Problems?

Posted on 2009-05-05
6
342 Views
Last Modified: 2012-05-06
I'm building a typical TCP Socket Server / Client in the usual way. Now I have a problem after encrypting the data. Both Client and Server have identical myCrypto classes and password123. I don't receive errors performing the Encryption on the Client, just during Decryption on the Server...

[Client]
publice void SendData(string message)
{
     Object oData = myCrypto.Encrypt(message, "password123");
     byte[] byteData = System.Text.Encoding.ASCII.GetBytes(oData.ToString());
}

[Server]
public  void DataRcvd(IAsyncResult aResult)
{
     string dataEncrypted = Encoding.ASCII.GetString(skt.byteBuffer, 0, skt.byteBuffer.Length);                                
     string dataDecrypted = myCrypto.Decrypt(dataEncrypted, "password123");
}
0
Comment
Question by:pointeman
  • 4
  • 2
6 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24310057
does (Server) string dataEncrypted   Equal (Client)  oData.ToString()  ?
0
 

Author Comment

by:pointeman
ID: 24316549
I'm check that out now...
0
 

Author Comment

by:pointeman
ID: 24317047
Go figure, for what ever reason, loading the received data into a textbox somehow fixes the problem, although I don't want to use a textbox because the Win-App is just a testing project to eventually build a Win-Service later....
public  void DataRcvd(IAsyncResult aResult)
{
     string dataEncrypted = Encoding.ASCII.GetString(skt.byteBuffer, 0, skt.byteBuffer.Length);                                
     
     textBox_ReceivedMsg.Text = dataEncrypted;

     string dataDECRYTPED = myCrypto.Decrypt(txtReceivedMsg.Text, "password123");

     textBox_Decrypted.Text = dataDECRYTPED;
}
 
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:williamcampbell
ID: 24318000
Maybe the line below will do it
string dataEncrypted = Convert.ToString (Encoding.ASCII.GetString(skt.byteBuffer, 0, skt.byteBuffer.Length));  
 

or
 

string dataEncrypted = Encoding.ASCII.GetString(skt.byteBuffer, 0, skt.byteBuffer.Length).ToString ();  

Open in new window

0
 

Author Comment

by:pointeman
ID: 24320809
No, both code suggestions failed because I now need to convert to base64, which I did, then I receive a padding error....
I guess I need to investigate how a TextBox converts input data.
0
 

Accepted Solution

by:
pointeman earned 0 total points
ID: 24337218
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now