Code Ratchet
Code Ratchet

Reputation: 6029

Cryptographic Exception Caught : Padding is invalid and cannot be removed

I have Googled and looked on SOF for a solution but sadly I'm a little confused on how to resolve this issue,

For Encryption I'm using the following

Simple insecure two-way "obfuscation" for C#

The way I use this the end user choose a category and saves the item, on returning from the DB I select the relevant view to be display.

The view name is then Encrypted and passed to a new action.

Within this Action I then try to decrypt the encrypted view name and pass it to the view to be rendered but when I try to decrypt it I get this error mentioned above, I'm uncertain on how to fix this.

My controller looks like this

             return RedirectToAction("Description", "Advert", new{
                        encryptedView = crypto.Encrypt(advertModel.View),
                    });

which passes the following encryption

too8kmao3odfbwbhlaod1w==

I then try the following in the action its been redirected to

var decryptView = new Crypto().Decrypt("too8kmao3odfbwbhlaod1w==");

yet with no avail.....

Upvotes: 0

Views: 77

Answers (1)

Code Ratchet
Code Ratchet

Reputation: 6029

Ok, found the solution as im using a nuget LowercaseRoutesMVC when I encrypt it, it looks like this

Too8KMao3ODfBWBHLaoD1w==

When I try to decrypt its lower case as mentioned above which is what causes the issue.

I'll have to think of another way to resolve this.

Upvotes: 1

Related Questions