I'm programming a device (MPOS) in C/C++ and I need to send encrypted data via TCP/IP to a socket server written in C#.
After encrypting the data (
) and transmitting it to the server, I always get an exception with the message "
Encrypting on the device is straight forward:
From the C# side, I'm using the Generic Symmetric Algorithm Helper.
(Generic SymmetricAlgorithm Helper
var keyString = "012345678901234567891234";
var key = Encoding.UTF8.GetBytes(keyString);
var sec = new Utilities.Crypto.SymmetricCryptography<TripleDESCryptoServiceProvider>(key, null);
var d1 = File.ReadAllBytes(@"c:\raw.txt");
var dec2 = sec.Decrypt(enc2);
For one thing, no IV is specified in the C encryption above. I modified the
's constructor a bit to auto generate the IV.
public SymmetricCryptography(byte key, byte iv)
_key = key;
if (iv == null)
_provider.Key = key;
iv = _provider.IV;
_iv = iv;
How do I get this to work?