Showing this error at browser when trying to open an PDF attachment file
Facing issue somtimes showing this error at browser when trying to open an PDF attachment file:
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..
At application.cfc:
<cfset application.sKey = generateSecretKey('AES')>
At view CFM:
<td>
<a target="_blank" href="#buildurl('newonlinesc.view_pdf&id=#encrypt("2||#rc.data.pass_no#", '#application.Key#', "AES", "HEX")#')#">View Emirates
</td>
Opening a PDF file (view_pdf.cfm):
<cftry>
<cfif structkeyexists(rc, 'type') AND len(rc.type)>
<cfheader name="content-disposition" value="inline; filename=#rc.pass_no#_#rc.type#">
<cfif listlast(rc.type,'.') EQ 'pdf'>
<cfset ctype = 'application/pdf'>
<cfelse>
<cfset ctype = 'image/jpeg'>
</cfif>
<cfcontent type="#ctype#" variable="#rc.docdata#">
<cfelse>
<cflocation url="#buildurl('newonlinesc.list')#" addtoken="false">
</cfif>
<cfcatch>
<cfdump var="#cfcatch#" abort="true"/>
</cfcatch>
</cftry>
