Us the DECRYPTBYPASSPHRASE function

  • I have a T-SQL script which encrypts the SSN using the ENCRYPTBYPASSPHRASE function with a pass phrase. ENCRYPTBYPASSPHRASE('Key', CAST(e.ssn AS nvarchar(100)))

    The ENCRYPT and DECRYPT function works fine when performed on the same server, which is SQL 2019.

    But, when I perform the ENCRYPT on server "A" . Then write the result set to server "B" and try to DECRYPT the column. It returns NULL?

    SELECT Convert(nvarchar(100),DECRYPTBYPASSPHRASE('Key',SSNEncrypt)) AS SSN

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Can't reproduce it

    DECLARE @source varbinary(4000)=0x0200000022695FA76ADC377F399412C032EFA78DA0E0DA5F2A7E20D880D6465AC72AD152;
    SELECT CONVERT(NVARCHAR(100), DECRYPTBYPASSPHRASE('Key',@source)) AS SSN

    Results in ABC on different collations

  • This was removed by the editor as SPAM

Viewing 4 posts - 1 through 3 (of 3 total)

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