locked
Redirect Page System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. RRS feed

  • Question

  • User-410257276 posted

    Dear Friend,

                         I am using ccavenue for payment gateway. when i am going to ccavenue its working. when i redirect to my page i am getting error on that page.

    System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
     

    STACK TRACE

    [CryptographicException: Padding is invalid and cannot be removed.]
       System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +4726976
       System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +296
       System.Security.Cryptography.CryptoStream.FlushFinalBlock() +34
       System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing) +86
       System.IO.Stream.Close() +21
       System.IO.StreamReader.Dispose(Boolean disposing) +89
       System.IO.TextReader.Dispose() +21
       ccavutil.AesCryptUtil.DecryptStringFromBytes(String encryptedText, Byte[] Key, Byte[] IV) +396
       ccavutil.AesCryptUtil.decrypt(String strToDecrypt) +64
       ResponseCancel.Page_Load(Object sender, EventArgs e) +108
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
       System.Web.UI.Control.OnLoad(EventArgs e) +95
       System.Web.UI.Control.LoadRecursive() +59
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +780

    And my redirect url page is 

     protected void Page_Load(object sender, EventArgs e)
        {
            string workingKey = "37AE80491E36777********"; // Testing Purpose
            //string workingKey = "**********************";//put in the 32bit alpha numeric key in the quotes provided here
            CCACrypto ccaCrypto = new CCACrypto();
            string encResponse = ccaCrypto.Decrypt(Request.Form["encResp"], workingKey);
            NameValueCollection Params = new NameValueCollection();
            //string[] segments = encResponse.Split('&');
            string ShipmetidArray = encResponse.Split('&')[0];
            string Shipmentid = ShipmetidArray.Split('=')[1];
            string RightsArray = encResponse.Split('&')[26];
            string Rights = RightsArray.Split('=')[1];
            string ClientIdArray = encResponse.Split('&')[27];
            string ClientId = ClientIdArray.Split('=')[1];
            string UsernameArray = encResponse.Split('&')[28];
            string Username = UsernameArray.Split('=')[1];
            Session["CLIENTID"] = ClientId;
            Session["RIGHTS"] = Rights;
            Session["USERNAME"] = Username;
            string Month = DateTime.Now.ToString("MMM").ToUpper();

    i searched more than 3 hours but i didn't get answer. Please tell how to slove this. I am waiting for your reply

    Friday, April 13, 2018 9:27 AM

Answers

  • User475983607 posted

    My best guess is an escaped value or you need to base64 before decrypting encResp. 

    Your best bet is to contact ccavenue payment gateway support as the error is in their API.   I'm sure their documentation explains how to handle the response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 13, 2018 11:58 AM

All replies

  • User475983607 posted

    My best guess is an escaped value or you need to base64 before decrypting encResp. 

    Your best bet is to contact ccavenue payment gateway support as the error is in their API.   I'm sure their documentation explains how to handle the response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 13, 2018 11:58 AM
  • User-410257276 posted

    Thank you so much

    Friday, April 13, 2018 12:22 PM