I want to store a string data to SQL server, but data should be stored in encrypted format. So for this I have used SQL server encryption and to store this value I have used varbinary column. But I am confused about the size of the column because when I encrypt the data (a string value), size of the encrypted data increases. For example,
OPEN SYMMETRIC KEY [mykey] DECRYPTION
BY CERTIFICATE[MyCertificate]
SELECT LEN(EncryptByKey (KEY_GUID('mykey'),CONVERT(nvarchar(8),'10/10/10')))
Results: 68
OPEN SYMMETRIC KEY [mykey] DECRYPTION
BY CERTIFICATE[MyCertificate]
select CONVERT(nvarchar(8),DECRYPTBYKEY(EncryptByKey (KEY_GUID('mykey'),CONVERT(nvarchar(8),'10/10/10'))))
Resuls: 8
I can set the size of varbinary column to 100 and proceed but there will be waste of some space.