0 Replies Latest reply on Apr 18, 2008 10:20 AM by Bob Flynn (IN Univ)

    decryptBinary() no longer working on large files after migration

    Bob Flynn (IN Univ)
      We are migrating from CF7 to CF8 and MS SQL Server 2000 to MS SQL Server 2005. We have a function that uploads and encrypts PDF files and writes them to the database. The PDFs range from 50KB to 10MB. It has been working fine for a year in the old setup. In or test environment for the new setup we get the error " An error occurred while trying to encrypt or decrypt your input string: Given final block not properly padded." when we try to open the larger PDFs. I don't know the exact cutoff, but it certainly seems to be anything over 1MB, possibly smaller.

      When originally setting this arrangement up, we were advised to make the datatype image to store the binary in SQL 2000. We left it that way for SQL 2005.I am not sure if I should be focusing my attention on CF, the code itself or SQL server. Any help would be greatly appreciated. The code for our CFC is below. Let me know if there is any other information I could provide to assist in troubleshooting.

      Cheers,

      Bob

      quote:

      <cfscript>
      theKey= ToBase64(BinaryDecode(" ourRandomStringHere", "Hex"));
      </cfscript>


      <cffunction name="Encrypt_Binary" access="public" returntype="any">
      <cfargument name="filedata" type="any" required="yes">
      <cfscript>
      filedata = encryptBinary(filedata, theKey, "AES");
      </cfscript>
      <cfreturn filedata>
      </cffunction>


      <cffunction name="Decrypt_Binary" access="public" returntype="any">
      <cfargument name="filedata" type="any" required="yes">
      <cfscript>
      filedata = decryptBinary(filedata, theKey, "AES");
      </cfscript>
      <cfreturn filedata>
      </cffunction>