Solved

Sockets ASCII & Base64 Encryption Problems?

Posted on 2009-05-05
6
347 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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 Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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