Data type for encrypted data input

  • Hi,

    I have a client C/C++ app, which encrypts data using AES encryption algorithm and stores them in the SQL Server database. I cannot decide which data type would be the best to store this type of input: VARCHAR(MAX) or VARBINARY(MAX).

    I tried to look for some comparisons of advantages and disadvantages or either particular type, but only I could see, was a mentioning of collation in the case of VARCHAR type. I would like to know if there are any performance implications due to conversions between char and binary types when writing and reading the data. Also,what would be the reason for not using BINARY type, and what would be the reason for not using the VARCHAR type?

    Thanks for help.

  • I would use varbinary(MAX), since the encrypted data is just a bunch of bits, which makes very little sense as characters.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

Viewing 2 posts - 1 through 1 (of 1 total)

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