Solved

Sockets ASCII & Base64 Encryption Problems?

Posted on 2009-05-05
6
338 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

25 Experts available now in Live!

Get 1:1 Help Now