SQL2005 Encryption problem
I am getting null values when i decrypt the encrypted column in my table. As of now, i have no idea where i went wrong. Here is the sql statement i used:
if not exists (select * from sys.symmetric_keys where symmetric_key_id=101)
create master key encryption by password =abc123456&*(‘
go
create certificate myportal
with subject =’Credit Card Certificate’
go
create symmetric key CommentKey
with algorithm = DES
encryption by certificate myportal
go
open symmetric key CommentKey
decryption by certificate myportal
go
update carddata
set creditcard= encryptbykey(key_guid(‘CommentKey’),’creditcard’)
go
/* now it shows the data in the creditcard column is encrypted */
select * from carddata
/* to reveal the data in the creditcard column */
open symmetric key CommentKey
decryption by certificate myportal
go
select firstname, lastname, convert(char,decryptbykey(creditcard)) as creditopen
from carddata
————————————
When the last command is run, i only get null values in the encrypted column….
Filed under: Computing