pointeman
asked on
Sockets ASCII & Base64 Encryption Problems?
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.ToSt ring());
}
[Server]
public void DataRcvd(IAsyncResult aResult)
{
string dataEncrypted = Encoding.ASCII.GetString(s kt.byteBuf fer, 0, skt.byteBuffer.Length);
string dataDecrypted = myCrypto.Decrypt(dataEncry pted, "password123");
}
[Client]
publice void SendData(string message)
{
Object oData = myCrypto.Encrypt(message, "password123");
byte[] byteData = System.Text.Encoding.ASCII
}
[Server]
public void DataRcvd(IAsyncResult aResult)
{
string dataEncrypted = Encoding.ASCII.GetString(s
string dataDecrypted = myCrypto.Decrypt(dataEncry
}
does (Server) string dataEncrypted Equal (Client) oData.ToString() ?
ASKER
I'm check that out now...
ASKER
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(s kt.byteBuf fer, 0, skt.byteBuffer.Length);
textBox_ReceivedMsg.Text = dataEncrypted;
string dataDECRYTPED = myCrypto.Decrypt(txtReceiv edMsg.Text , "password123");
textBox_Decrypted.Text = dataDECRYTPED;
}
public void DataRcvd(IAsyncResult aResult)
{
string dataEncrypted = Encoding.ASCII.GetString(s
textBox_ReceivedMsg.Text = dataEncrypted;
string dataDECRYTPED = myCrypto.Decrypt(txtReceiv
textBox_Decrypted.Text = dataDECRYTPED;
}
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 ();
ASKER
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.
I guess I need to investigate how a TextBox converts input data.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.