Decrypt a symmetric key encrypted value fails

  • So, I am trying to encrypt some sensitive data. I am using symmetric key encryption by password.

    I've created a master key. I've created a symmetric key (tried various algorithms and none work).

    I then test with this code and the decrypting of the data does not work. The decrypted value is just garbage data, rather than matching the original unencrypted data.

    declare @a varbinary(max)

    OPEN SYMMETRIC KEY MySymmetricKey

    DECRYPTION BY PASSWORD = 'AWickedStrongPass0rd!!!'

    set @a = EncryptByKey(Key_GUID('MySymmetricKey'), 'SensitiveData')

    select @a -- Show me the encrypted value (so far so good)

    select convert(nvarchar(max), DecryptByKey(@a)) -- When data is decrypted it's "garbage data". Example: 㠴㠰㄰〷㈰㌳㜸㠸

    Please help!



    A.J.
    DBA with an attitude

  • I just realized I posted this in the SQL 7/2000 forum... I meant to post in 2005/2008. Moderator... please close this and I will repost it in the proper spot.



    A.J.
    DBA with an attitude

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

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