You need to sign in to do that
Don't have an account?
Gautam_Kasukhela
Encryption Decryption Issue
Hello All,
I am facing a strange issue when decrypting a String that was encoded on the platform. Here is the scenario:-
I have a String named quoteId and I am encrypting the quoteId using AES256 alogorithm and key. Post the encryption, I am encoding it using Base64 encoding. The result is something like the below
Encrypted String: jVWhnAUT6aoQFEOPmkJp/7QpE3V7uo2LjzC5VUWp31c=
Post encryption, I append the value to a URL query parameter, something like:
https"//xxxxxx?quoteId=jVWhnAUT6aoQFEOPmkJp/7QpE3V7uo2LjzC5VUWp31c=
Now when I decode and decrypt the value after reading the URL Params, it works fine and I am able to see the actual quoteId.
When I encrypt again another encrypted string is generated, something like: ZOWKWKWTSL8QIe7N8B3u80dC+hsmGFQIF0VjVGiB2II=
However, when the decode and decrypt the above, it does not work and I get a error saying "FATAL_ERROR System.SecurityException: last block incomplete in decryption".
What could be the issue? As the encryption, encoding , decoding and decryption logic is the same. Only observation that I have made is whenever there is a '+' in the generated encoded string, an exception is thrown. Is there anything that is probably throwing it off from the URL parameters?
Here is the code snippet
I am facing a strange issue when decrypting a String that was encoded on the platform. Here is the scenario:-
I have a String named quoteId and I am encrypting the quoteId using AES256 alogorithm and key. Post the encryption, I am encoding it using Base64 encoding. The result is something like the below
Encrypted String: jVWhnAUT6aoQFEOPmkJp/7QpE3V7uo2LjzC5VUWp31c=
Post encryption, I append the value to a URL query parameter, something like:
https"//xxxxxx?quoteId=jVWhnAUT6aoQFEOPmkJp/7QpE3V7uo2LjzC5VUWp31c=
Now when I decode and decrypt the value after reading the URL Params, it works fine and I am able to see the actual quoteId.
When I encrypt again another encrypted string is generated, something like: ZOWKWKWTSL8QIe7N8B3u80dC+hsmGFQIF0VjVGiB2II=
However, when the decode and decrypt the above, it does not work and I get a error saying "FATAL_ERROR System.SecurityException: last block incomplete in decryption".
What could be the issue? As the encryption, encoding , decoding and decryption logic is the same. Only observation that I have made is whenever there is a '+' in the generated encoded string, an exception is thrown. Is there anything that is probably throwing it off from the URL parameters?
Here is the code snippet
https://developer.salesforce.com/forums/?id=906F00000008ysEIAQ
Thanks.