Thanks for the advice, that was the problem. In fact, the real problem is that PaddingMode.PKCS7 doesn't work properly. Using this mode, in the roundtrip, I always get the error "PKCS7 padding is invalid and cannot be removed.". That's why I tried to do the padding myself, but it is not possible to do it in the string, because of the special characters that takes more than one byte. So, the solution was: I implemented the PKCS7 myself, in the byte array, right before the encryption, using PaddingMode.None for the RijndaelManaged. That worked fine. However, in the decryption, it was not necessary to implement it, the PaddingMode.PKCS7 worked correctly. Thanks to this article, "Notes On Padding" section: http://www.codeproject.com/KB/security/Cryptor.aspx[^]