Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can I encrypt ntext and nvarchar(max) columns ?


Can I encrypt ntext and nvarchar(max) columns ?

Author
Message
onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
Hello, I just want to know :

can I encrypt ntext and nvarchar(max) columns in SQL 2005, using AES 128 ?
Mike C
Mike C
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1351 Visits: 1168
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.
onlo
onlo
SSC Veteran
SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)SSC Veteran (207 reputation)

Group: General Forum Members
Points: 207 Visits: 612
Thanks,

but are there any Web sites or documents which tell me how to append the encrypted data chunk together ?
Mike C
Mike C
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1351 Visits: 1168
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search