EXP Bad data in RSA client server app

Oct 15, 2013 at 2:29 AM
I am receiving a CryptographicException stating "Bad Data" when attempting to decrypt data sent across the network encrypted using RSACryptoServiceProvider.

I receive no exceptions client side when attempting to send the data.

Client:

public byte[] ENC(string strdata, CspParameters prk)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(prk);
byte[] data = rsa.Encrypt(Encoding.Unicode.GetBytes(strdata),false);
MessageBox.Show(data.Length.ToString());/////test
return data;
}

void clint(byte[] data)
{
try
{
    object op = (object)data;
    BinaryFormatter br = new BinaryFormatter();
    TcpClient myclient = new TcpClient("192.168.43.152", 7000);
    NetworkStream myns = myclient.GetStream();
    br.Serialize(myns, op);
    myclient.Close();
}
catch (Exception e)
{
    clint(data);
}
}

CspParameters cp = new CspParameters();
cp.KeyContainerName = "25522100";
string usb = ":RIO";
string Name = System.Environment.MachineName;
Name += usb;
mymsg = ENC(Name, cp);
clint(mymsg);
Server:

TcpListener mytcp = new TcpListener(7000);
mytcp.Start();
TcpSocket mysocket = mytcp.AcceptSocket();
NetworkStream myns = new NetworkStream(mysocket);
BinaryFormatter br = new BinaryFormatter();
object op;
op = br.Deserialize(myns);
byte[] data = (byte[])op;
CspParameters cp = new CspParameters();
cp.KeyContainerName = "25522100";
byte[] messge = DEC(data, cp);

public byte[] DEC(byte[] en_data, CspParameters key)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(key);
byte[] data1 = rsa.Decrypt(en_data, false);
return data1;
}
Why am I receiving this CryptographicException when attempting to decrypt the received data?