SQLTeam.com | Weblogs | Forums

Column Encryption working when Key is closed


#1

I may have a few queries on encryption.

I was trying to understand if opening a key is required each time we encrypt/decrypt. But something is confusing me. I run this. I don't understand why it works. Why isn't this giving an error?

CLOSE SYMMETRIC KEY ClaimantNameKey
GO


UPDATE tmpClaimantEncrypted   
SET NameEncrypted = 
    EncryptByKey(Key_GUID('ClaimantNameKey'), Name)
    where ID = 1953996
GO

#2

... OK, I see what's happening here. It doesn't work unless I open the key.

But shouldn't there be an error? i.e. Key is close, open Key first.

Also, there must be something I'm missing. As long as you know the name of the key, you can decrypt it. Seems to easy.