I need to broadcast a confidential data (a simple string) on the network (via socket, wcf, web services, not very matter how the way).
Well, I’ve just created a serializable class with an encrypted string and just one method to decrypt it which return decrypted data.
Is it a good solution to implement? Or maybe I’ll never should include in my object “the decrypt method” for an serialized object relayed on the network?
If you don’t care about the way it’s done then why not just put the receiving end as a web service with an HTTPS certificate? That way you don’t have to care about encryption or decryption or key exchange.
If you don’t want to do that then it’s sent over the wire via the methods you listed it’s just going to be a message containing property values – code doesn’t get sent. If someone sniffs it, and doesn’t have access to your classes, and your encryption is sound you’ll be ok.