Can I encrypt ntext and nvarchar(max) columns ?

  • Hello, I just want to know :

    can I encrypt ntext and nvarchar(max) columns in SQL 2005, using AES 128 ?

  • The symmetric key encryption functions max out at 8,000 bytes returned. With SQL Server metadata and AES block size this means you can encrypt slightly less bytes than that in one shot. About 7,950+ bytes or so. You can encrypt in groups of 7,950 bytes and append all of the groups together. Then you'll also need a routine to decrypt the blocks and append the results of decryption together to reassemble your source document.

  • Thanks,

    but are there any Web sites or documents which tell me how to append the encrypted data chunk together ?

  • The encryption and decryption functions return a varbinary(8000). Just use the + append operator and a WHILE loop. There are a few blogs worth checking out, especially the first one - it has an LOB encryption/decryption example:

    http://blogs.msdn.com/yukondoit/archive/2005/11/24/496521.aspx

    http://blogs.msdn.com/raulga/

    http://blogs.msdn.com/sqlsecurity/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply