-1

Below is my scenario

  1. I receive encrypted value(using DBMS_CRYPTO.ENCRYPT_3DES_2KEY) from client in text file ( Encryptions done in Oracle)
  2. I receive the key(AES192 30 character key) from client which is used for encryption.

I am using SQL Server 2012. How can i decrypt this value in SQL OR C#?

RobertKing
  • 1,853
  • 8
  • 30
  • 54

1 Answers1

0

This essentially requires to follow below mentioned step:

  1. Verify SQL Server Master Key
  2. Create a Master Key Encryption password
  3. Create a self signed certificate
    • A certificate is a digitally signed security object that contains a public (and optionally a private) key for SQL Server
  4. Create Symmetric Key.
  5. Encrypt the column(needs to be varbinary type)

To add records:

sample syntax:

OPEN SYMMETRIC KEY SymmetricKey1 DECRYPTION BY CERTIFICATE Certificate1;
-- Performs the update of the record 
   INSERT INTO dbo.test VALUES 
    (x, EncryptByKey(Key_GUID('SymmetricKey1'), CONVERT(varchar,'4545-58478-1245'))); 
   GO

For step by step execution, follow this mssqltips article

Prabhat G
  • 2,974
  • 1
  • 22
  • 31
  • I am receiving already encrypted value which i need to decrypt before use – RobertKing Feb 21 '18 at 12:18
  • If you read the link above, then you'll come to know that you anyway have to create certificate and symmetric key in sql server before you can use it for decryption. I'll keep you updated incase there's alternate way – Prabhat G Feb 21 '18 at 12:20
  • I think your suggestion does not work for his case. The guy needs to use an existing key to decrypt an already encrypted value. I don't think you can create a SymKey from an existing key. – kirchner Feb 21 '18 at 12:23