The scenario: you've got some data you'd like to keep private, so you've encrypted it on your web server using
PHP's handy mcrypt functions using (for example) TripleDES. You go to decrypt the data on client side using
DotNet System.Security.Cryptography, but no dice, you just get the helpful error 'Bad Data.'.
The problem is in the padding. If you examine an 8 character string encrypted with DotNet, you get a 16 character ciphertext. DotNet apparently defaults to PKCS7 padding, which is not compatible with mcrypt and mcrypt pads with spaces. So as long as you trim your in/output, and set your:
CryptoServiceProvider.Padding = PaddingMode.None;
and you should be ready to go. This method is probably preferable to reverse-engineering PKCS7 from the DotNet cipher and implementing it in PHP wrappers before noticing the .Padding property.
$imod = strlen($plain_text) % 8;
$ipad = 8 - $imod;
for ($iX = 0; $iX < 8 - $imod; $iX++)
$plain_text .= chr($ipad);