Encryption error when changing platforms RRS feed

  • Question

  • I have a .NET 4.0 web application that needs to encrypt and decrypt some data.  The web app has multiple pages, and users navigate by clicking a "next" button.  When the button is clicked, the information entered on that page is encrypted if needed and then saved into a database.  If a user completes the series of forms from first to last page on any platform in any browser, there are no issues.  However, I have run across an interesting issue.

    If a user starts the series of forms on an iOS device (tested with iPad and iPhone), but then decides to move to a desktop computer (tested on Windows 7 machine using IE 9, firefox 13, chrome 19, and safari 5.1.7), they will error out when the form tries to populate itself with information that the user had entered on the iPad.  The error is thrown in the decrypt method.  It is a cryptographic error with the message "Padding is invalid and cannot be removed."

    Top of the stack:

    at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
    at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
    at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count)

    Any ideas?

    • Moved by Min Zhu Monday, June 25, 2012 3:27 AM (From:.NET Base Class Library)
    Thursday, June 21, 2012 7:31 PM