Dean Lawrence
05/18/2023, 2:40 PM<cfset unsubscribeValues = MailingListID & "|" & mailingNum />
<cfset unsubscribeVars = encrypt(unsubscribeValues, encryptKey, "AES/CBC/PKCS5Padding", "HEX") />
And adding as a link in my emails.
<a href="#domain#/unsubscribe?v=#encodeForURL(unsubscribeVars)#">Unsubscribe</a>
When someone clicks the unsubscribe link, I am using the following code to decrypt the string.
<cfset var unsubscribeVars = decodefromUrl(arguments.event.getValue("v")) />
<cfset var unsubscribeValues = len(unsubscribeVars) ? decrypt(unsubscribeVars, encryptKey, "AES/CBC/PKCS5Padding", "HEX") : "" />
Half the times that someone tries to unsubscribe, it works fine. The other half though, it throws an error when trying to decrypt the string with the following error:
An error occurred while trying to encrypt or decrypt your input string: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
Both encrypt/decrypt functions are using the same key. Am I doing something wrong? Is there a better way to do this? Any help would be appreciated.Brian Reilly
05/18/2023, 3:53 PMDean Lawrence
05/18/2023, 4:06 PMBrian Reilly
05/18/2023, 4:11 PMDean Lawrence
05/18/2023, 4:12 PMBrian Reilly
05/18/2023, 4:40 PMDean Lawrence
05/18/2023, 4:44 PMBrian Reilly
05/18/2023, 4:57 PMDean Lawrence
05/18/2023, 7:09 PMMatt Jones
05/19/2023, 7:42 PM