Hi All When storing an encrypted field in an SQL ...
# cfml-general
m
Hi All When storing an encrypted field in an SQL Server Database what's the ideal data type to use to store it? I am attempting to store an image converted to base64 which is then encrypted and inserted into a varbinary(MAX) field in the database. However, when it inserts into that database it looks completely different from the output I see on the screen. For example after the base64 conversion and encryption it stores the field like this : 0x33F104E49F83DC517A3001472C247C5764CEF0C5 BUT on the screen it shows this. Am I storing it using the wrong data type in the database ??
g
My initial thought is: Have you tried to get it back out? and did that give you the results you expect? In essence I think I am saying - as long as you put it in and get it out and use - does it matter if the string representation isn't exactly as you expect? And just as I wrote that, I am thinking... "But if I don't actually know for certain what is supposed to look like at every step - is each step actually doing what I think it is". I am a living paradox at times! πŸ˜‰
m
Hey @gavinbaumanis I just stored the encrypt and decrypt values in the database as nvarchar(MAX) which seems to have done the trick 😬
πŸ‘πŸΌ 1
g
Awesome! and I bet it happened less than a minute after you posted, right?
m
πŸ˜‚ πŸ˜‚ always the way
πŸ˜‚ 1
Thanks πŸ™ @gavinbaumanis
g
I did nothing - but will accept your thanks with the greatest humility....
πŸ˜‚ 2
a
looks like you don't actually need
nvarchar
and
varchar
will still work if you care about saving a few bytes
m
Ah ok cheers @aliaspooryorik
t
nvarchar is probably better for unicode support with encrypted characters that could potentially be non-english
πŸ™ 1
You can probably get away with varchar but there isn’t much reason to unless you’re really worried about the fixed allocation of nvarchar and the impact that can have on row size
a
yeah - I wouldn't worry about it but sometimes row size is an issue